I have an XML document of the form:
<metadata>
<item name="Name" type="xs:string" length="102"/>
<item name="Email" type="xs:string" length="202"/>
</metadata>
<data>
<row>
<value>Daniel</value>
<value>daniel@no-reply.com</value>
</row>
<row>
<value>George</value>
<value>george@no-reply.com</value>
</row>
</data>
The ordering and number of columns may change so it is not sufficient to assume //row/value[1]/text() always holds ‘Name’.
What is the best way to query the document using the metadata names to pull the right values?
I am querying the document in C#.NET3.5 so can use XDocument, XPath etc… whichever is the best for the job.
Personally, I would transform this input (is it plist?) into a “real” XML document where the tags have better names (i.e. the metadata description). You can achieve this by using xsl transformation and a selfwritten stylesheet (can assist if needed).
After that, you would have a structure like:
Now then it’s easy to address the nodes using
/data/row/Nameand selecting them with an XPathNavigator