xpath - C# XPathSelectElement returns null -
i trying use xpathselectelement method of system.xml.xpath namespace reason returns null, , have no idea why.
here code:
textreader stream = new streamreader("config.ini"); xmlreader reader = xmlreader.create(stream); xelement xml = xelement.load(reader); xelement file = xml.xpathselectelement("config/file");
here xml file trying read:
<?xml version="1.0" encoding="utf-8"?> <config> <file>serp_feed.xml</file> </config>
i have tried many things (adding namespace table, changing xpath, etc.) nothing works!
any ideas?
well xelement.load
variable named xml
root element, "config" element of xml sample posted. , if use path config/file
on element context node looking child element named "config" having descendant "file" element. "config" element not have "config" child element, has "file" child element. want xpath file
or need xdocument xml = xdocument.load("config.ini)
, path works.
Comments
Post a Comment