xpath syntax to get element with specific xmlns attribute

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
<div style="background-color:white; color:black
<pre><span style="color:blue <<span style="color:#a31515 b <span style="color:red xmlns<span style="color:blue =<span style="color:black "<span style="color:blue nmspc<span style="color:black " <span style="color:blue />

[/code]

whats the xpath syntax to grab this elements?
I can get it with
<pre lang="x-c# XmlNamespaceManager xnsMgr = ...

xmlDoc.DocumentElement.SelectNodes(string.Format("//{0}:*", prefix), xnsMgr)

[/code]

<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small but i would like to target element that explicitly has that xmlns attribute, i tried below, non of them worked:
<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small
<pre lang="x-c# XmlNodeList xNs2 = xmlDoc.DocumentElement.SelectNodes(string.Format("//*[@xmlns={0}]", uri), xnsMgr);

XmlNodeList xNs4 = xmlDoc.DocumentElement.SelectNodes(string.Format("//*[@xmlns={0}]", uri));

XmlNodeList xNs3 = xmlDoc.DocumentElement.SelectNodes(string.Format("//{0}:*[@xmlns={1}]", prefix, uri), xnsMgr);
[/code]
<span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small <span style="font-family:Consolas; color:#2b91af; font-size:x-small

<span style="font-family:Consolas; font-size:x-small

View the full article
 
Back
Top