# xml help

**URL:** <https://forums.powershell.org/t/xml-help/13004>\
**Category:** PowerShell Help\
**Created:** [August 15, 2019, 8:23pm UTC](https://forums.powershell.org/t/xml-help/13004 "2019-08-15T20:23:08Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![john-curtiss](https://avatars.discourse-cdn.com/v4/letter/j/f1d935/32.png) [@john-curtiss](https://forums.powershell.org/u/john-curtiss)\
**Post date:** [August 15, 2019, 8:23pm UTC](https://forums.powershell.org/t/xml-help/13004/1 "2019-08-15T20:23:08Z")

</div>

in this xml, what are FTP, SSHFTP, and Share considered/called, and how would I extract them with powershell? in other words, if I wanted to populate an array with type, Id, Name, where “type” is ftp, sshftp, or share, how would I get the type with powershell?

I’ve imported it with get-content as [xml] and I can get to $xml.settings.hosts.

from there, if I do $xml.settings.hosts.ftp, I see a chart (looks like an array, but get-member tells me it’s an xmlelement) with all the ftp IDs and Names, but I don’t actually see the label “ftp” anywhere. and the parentnode is “hosts,” not “ftp.”

\<script src=“[https://gist.github.com/Curtmcgirt/522c5b2224189dc365059c62d175d8aa.js](https://gist.github.com/Curtmcgirt/522c5b2224189dc365059c62d175d8aa.js)”\>\</script\>

---

<div class="post-metadata">

**Author:** ![kvprasoon](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/kvprasoon/32/4449_2.png) [@kvprasoon](https://forums.powershell.org/u/kvprasoon)\
**Post date:** [August 15, 2019, 10:23pm UTC](https://forums.powershell.org/t/xml-help/13004/2 "2019-08-15T22:23:56Z")

</div>

FTP here is a not a type, its an XML element even if its a type your purpose. You can use get\_name() method which will give the element name.

---

<div class="post-metadata">

**Author:** ![nitbha](https://avatars.discourse-cdn.com/v4/letter/n/6a8cbe/32.png) [@nitbha](https://forums.powershell.org/u/nitbha)\
**Post date:** [August 15, 2019, 10:26pm UTC](https://forums.powershell.org/t/xml-help/13004/3 "2019-08-15T22:26:57Z")

</div>

[John Curtiss](https://powershell.org/profile/John-Curtiss/)

convert your xml to PScutomerobject then you will get more flexibility to use it **Example** : (Easy way as I don't know how you going to use this xml file ) as below example below 3 PowerShell objects created $PSObjectftp,$PSObjectSSHFTP,$PSObjectShare

===========================================================================================

```
$Share=@()
$SSHFTP=@()
$FTP=@()

[xml]$xml=gc -path "d:\abc.xml"
$ftp+=$xml.GetElementsByTagName('FTP')
$SSHFTP+=$xml.GetElementsByTagName('SSHFTP')
$Share+=$xml.GetElementsByTagName('Share')

$PSObjectftp = New-Object PSObject
foreach ($Property in $ftp) {
$PSObjectftp | Add-Member NoteProperty $Property.id $Property.name
}

$PSObjectSSHFTP = New-Object PSObject
foreach ($Property in $SSHFTP) {
$PSObjectSSHFTP| Add-Member NoteProperty $Property.id $Property.name
}

$PSObjectShare = New-Object PSObject
foreach ($Property in $Share) {
$PSObjectShare | Add-Member NoteProperty $Property.id $Property.name
}
```

---

<div class="post-metadata">

**Author:** ![john-curtiss](https://avatars.discourse-cdn.com/v4/letter/j/f1d935/32.png) [@john-curtiss](https://forums.powershell.org/u/john-curtiss)\
**Post date:** [September 6, 2019, 11:33am UTC](https://forums.powershell.org/t/xml-help/13004/4 "2019-09-06T11:33:10Z")

</div>

get\_name() got the job done. I didn’t see that in the list of methods when I did get-member. i’m sure there’s a good reason for that. I see these.

GetAttribute  
GetAttributeNode  
GetElementsByTagName  
GetEnumerator  
GetHashCode  
GetNamespaceOfPrefix  
GetPrefixOfNamespace  
GetType

&nbsp;

---

<div class="post-metadata">

**Author:** ![kvprasoon](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.powershell.org/kvprasoon/32/4449_2.png) [@kvprasoon](https://forums.powershell.org/u/kvprasoon)\
**Post date:** [September 6, 2019, 11:45am UTC](https://forums.powershell.org/t/xml-help/13004/5 "2019-09-06T11:45:33Z")

</div>

do Get-Member with -Force

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:31pm UTC](https://forums.powershell.org/t/xml-help/13004/6 "2024-05-16T20:31:42Z")

</div>

Closed on May 16, 2024, 8:31pm UTC


