Printing XmlElement names in PowerShell


I have a XML document:

and a powershell script accessing data from that document. I need to iterate by the children of Root and print the element names of its children. Example:

Update: As MrKWatkins correctly pointed out below in this case I could use the LocalName property instead. However this will not work if I’m using namespaces of if I also have a LocalName attribute in my XML. I would like to know if exists a solution for this problem that always works no matter the XML file.


You can do something like this:


Printing XmlElement names in PowerShell by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply