Quantcast
Channel: XML, System.Xml, MSXML and XmlLite forum
Viewing all articles
Browse latest Browse all 935

XPath doesn't point the right element

$
0
0

I have an XML source that I load it in c# by XmlDocument. I need to access one element in this source that this element uses a prefix called xsl. When I've tried to get the element with XPath command, the right element isn't returned. Instead, other element that have xsl prefix returned. I tested the XPath command in XMLSpy and it works correctly.

<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><table border="1"><thead><tr><!--<th><span><xsl:text>HeaderSample</xsl:text></span></th>--></tr></thead><tbody><!--I need the below element--><xsl:for-each select="result1"><xsl:for-each select="row"><tr><td><xsl:for-each select="HeaderSample"><xsl:apply-templates/></xsl:for-each></td></tr></xsl:for-each></xsl:for-each></tbody></table></xsl:stylesheet>				 						

XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
            nsmgr.AddNamespace("xsl", "http://www.w3.org/1999/XSL/Transform");

            XmlNode resultName = doc.LastChild.SelectSingleNode("table/tbody/xsl:for-each[1]", nsmgr);

How can I fix it?



Viewing all articles
Browse latest Browse all 935

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>