I have some XML:
<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP:Body>
<P2MessageServiceStatus>
<CONNECTION>CONNECTION_CONNECTED</CONNECTION>
<ROUTER>ROUTER_CONNECTED</ROUTER>
</P2MessageServiceStatus>
</SOAP:Body>
</SOAP:Envelope>
Can't deal with it because of namespaces. Trying a lot, but not working.
[string]$xpath = '/SOAP:Envelope/SOAP:Body/P2MessageServiceStatus/@CONNECTION'
$wc = New-Object Net.WebClient
[xml]$stuff = $wc.DownloadString($url)
$ns = New-Object Xml.XmlNamespaceManager $stuff.NameTable
$ns.AddNamespace("SOAP", $xmlns)
$xmlvalue = $stuff.SelectSingleNode($xpath, $ns)
Error - need Namespace manager or XsltContext
If
$xmlvalue = $stuff.SelectSingleNode($xpath,'SOAP')
Error - Unable to find overload for "SelectSingleNode"
How to make that xpath query work with namespaces?