I have code like so:
string xml = "<root><span tag=\"LUMP\" missingValue=\"3,4,5,6,7,8\" format=\"Disc\" varName=\"RACE\" label=\"Race/ethnicity\"><element value=\"1+2\" label=\"Total 1+2\" /><element value=\"1\" label=\"White\" /><element value=\"2\" label=\"Black or African American\" /></span></root>";
doc.LoadXml(xml);
XmlNodeList varsList = doc.SelectNodes("span");
But everytime varsList is empty. Why?
"span" XPath means "immediate child nodes with name span". Since immediate child is root you get nothing.
You want either "//span" (all spans anywhere in the tree starting from root) or "/root/span" ("root" at root, than its "span" children).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With