I'm currently writing a C# class that allows me to construct entities from an OData feed. Don't ask why, I just need it at the moment :)
The snippet of the XML looks like this:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<entry xml:base="http://demo.tenforce.acc/Api.svc/" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
<id>http://demo.tenforce.acc/Api.svc/Items(387)</id>
<title type="text"></title>
<updated>2011-09-22T07:35:54Z</updated>
<author>
<name />
</author>
<link rel="edit" title="Item" href="Items(387)" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Children" type="application/atom+xml;type=feed" title="Children" href="Items(387)/Children" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Parent" type="application/atom+xml;type=entry" title="Parent" href="Items(387)/Parent" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Attachments" type="application/atom+xml;type=feed" title="Attachments" href="Items(387)/Attachments" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Predecessors" type="application/atom+xml;type=feed" title="Predecessors" href="Items(387)/Predecessors" />
<link rel="http://schemas.microsoft.com/ado/2007/08/dataservices/related/Successors" type="application/atom+xml;type=feed" title="Successors" href="Items(387)/Successors" />
<category term="TenForce.Execution.Api2.Objects.Item" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<content type="application/xml">
<m:properties>
<d:Id m:type="Edm.Int32">387</d:Id>
</m:properties>
</content>
</entry>
I've created a code snippet that loads the entire xml string into an XmlDocument, and generates a XmlNamespaceManager as well to have access to the various namespaces.
I'm trying to select the <category>
element from the XML but I can't seem to get the Xpath expression right. I've tried the following:
- //entry/category
- descendant::xmlns:cateogry
- //d:category
- //m:category
- //category
- //xml:category
But none seem to be selected the node in question.