How can I get the innertext of a xml node based on his attribute (type string)?
My XML-File looks following.
<?xml version="1.0" encoding="UTF-8" ?>
<office:document-content office:version="1.2">
<office:body>
<office:text>
<table:table table:name="Tabelle6" table:style-name="Tabelle6">
<table:table-row>
<table:table-cell table:style-name="Tabelle6.A1" office:value-type="string">
<text:p text:name="Invoice" text:style-name="P6">0001</text:p>
</table:table-cell>
</table:table-row>
</table:table>
</office:text>
</office:body>
</office:document-content>
I want to get the invoice number (0001) from this xml file. My code looks like this
var xml = XDocument.Load(filePath);
var query = from item in xml.Elements("text:p")
where (string)item.Attribute("text:name").Value == "Invoice"
select item.Value;
If I execute this, I get an error:
The ': ' character, hexadecimal value 0x3A, must not be contained in a name.
Maybe it's important, the content.xml
is a part of a extracted .odt
-File.