I am trying to search an xml element from the root element of the file on the basis of inner text. i have tried this but didnt work:
rootElRecDocXml.SelectSingleNode("/ArrayOfRecentFiles[name='"+mFilePath+"']");
I know the old school way to traverse all file element by element but i dont want to do that.
Please note that: my root element name is ArrayOfRecentFiles and my child element name are RecentFile
We’d need to see the xml; @Lee gives the correct approach here, so something like:
(taking your edit/reply into account)
However! There are lots of gotchas:
<foo>abc</foo>is different to<foo> abc[newline]</foo>etc – ditto carriage return).SelectSingleNode("/alias:ArrayOfRecentFiles[text()='"+mFilePath+"']", nsmgr);, wherensmgris the namespace-managerTo give a complete example, that matches your comment:
Here,
elis notnullafter theSelectSingleNodecall. It finds the node.