select-xml

for openers, how do I post sample xml to this forum? the “pre” stuff isn’t working for me.

easiest way is to use gist

so here is some xml. it’s an RDG file from microsoft’s Remote Desktop Connection Manager.

assume $xml = [xml](get-content testrdg.rdg)

$xml.rdcman.file.group.server.name returns “testserver”.

$xml.selectnode(“//rdcman/file/group/server/name”) returns nothing
$xml | select-xml -XPath “//rdcman/file/server/properties/name” returns nothing

I’ve read that this has to do with “namespace,” and I have to define a namespace. but I don’t see a namespace defined in that xml, so I don’t know how to decide what namespace to tell powershell to use.

crickets?

XPath is case-sensitive.

Using your example XML, these work.

Select-Xml -Xml $xml -XPath "//RDCMan/file/group/server/properties/name"
$xml.SelectNodes("//RDCMan/file/group/server/properties/name")