<?xml version="1.0" encoding="utf-8"?>
<Report p1:schemaLocation="TemplateXXX http://localhost?language=en" Name="TemplateXXX" xmlns:p1="http://www.w3.org/2001/XMLSchema-instance" xmlns="TemplateXXX">
<HEADER attr1="one" attr2="two" />
<Table filename="12345.pdf">
<left>
<details>
<item/>
<item/>
</details>
</left>
<right>
<details>
<item/>
<item/>
</details>
</right>
</Table>
</Report>
I'm running into a strange problem when trying to query elements and attributes in an xml document where a namespace is in the xml.
When I try to query the document to get the header element with the following xpath query I consistantly get null results
XDocument root = XDocument.Load(filePath);
var element = root.XPathSelectElement("/Report/HEADER");
This always returns null however the moment I remove the namespace from the document the query returns the exepcted element.
What is it that I'm getting wrong as I'm getting some what frustrated.
edit: updated xml to valid xml