This bit
var affidavits = xDocument.Descendants("AFFIDAVIT");
does not work because AFFIDAVIT is in the http://pria.org namespace. This should work (not tested it):
var affidavits = xDocument.Descendants("{http://pria.org}AFFIDAVIT");
An alternative to this, without having to hardcode the namespace in the code, is to use the node root namespace as follows:
var affidavits = xDocument.Descendants(xDocument.Root.Name.Namespace + "AFFIDAVIT");
xpath does not work due to case sensitivity. For starters, it should be
var affidavitsTest = xDocument.XPathEvaluate("/REETA/AFFIDAVIT/COUNTY_NAME");
As in REETA , not REETA . It will also have namespace problems after eliminating case sensitivity. I'm not too sure how to specify namespaces in XPath though.
source share