Click to See Complete Forum and Search --> : XPath in C# problems


mrand01
March 8th, 2005, 03:18 PM
I have an XMLNode that looks like this:


<div v:shape="_x0000_s30734" class="CT" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:def="http://www.w3.org/TR/REC-html40">
<span style="position:absolute;&#xD;&#xA; top:28.51%;left:9.45%;width:81.62%;height:9.38%"><span lang="EN-US"><br /></span></span><span style="position:absolute;top:36.1%;left:9.45%;width:81.62%;&#xD;&#xA; height:9.38%"><span lang="EN-US" style="mso-special-format:lastCR;display:none"></span></span></div>


I'm running an XPath statement on this node that is supposed to find all of the "span" nodes located under the root "div" tag. The XPath statement I have is:


/def:div/def:span


and I'm calling it like this:


XmlNodeList xmlSpans = xmlDiv.SelectNodes("/def:div/def:span", xmlns);


this, for some reason, returns absolutely nothing. I know my XmlNamespaceManager is correct, I can run valid XPath statements on other documents using these namespaces. I found a tool called Visual XPath, and loaded the XMLNode (I saved the OuterXML to a document and named it div.xml) into this program, then tried to run the same exact XPath statement there...and it worked! And this program was coded in C#...so I have no idea why my statement isn't working. Anyone have any ideas?