Skip to main content
Published: November 07 2005, 1:00:00 AMUpdated: July 26 2022, 5:54:20 AM

I am having a problem parsing Unified Schema XML responses.
How do I parse the Unified Schema in C#?

Using C#:
Since the Unified Schema uses namespaces, you must define an XmlNamespaceManager object for "urn:ebay:apis:eBLBaseComponents".
Each DOMDocument operation must pass this XmlNamespaceManager object as a parameter.
Each node should also be qualified with 'ebay:'

For example,
Let' say you have the response for GeteBayOfficialTime in an XmlDocument object, and you want to access the nodes in the XML, here is how you would go about doing it:

// xmlDoc is your document with the GeteBayOfficialTime response
// first define an XmlNamespaceManager object
XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDoc.NameTable);
// you must add the namespace used by the eBay Unified Schema API
nsmgr.AddNamespace("ebay", "urn:ebay:apis:eBLBaseComponents");
// let's get the GeteBayOfficialTimeResponse node
XmlNode ResponseNode = xmlDoc.SelectSingleNode("ebay:GeteBayOfficialTimeResponse", nsmgr);
// keep in mind that every node that you want to access must have the "ebay" namespace appended to it as well as refer to the XmlNamespaceManager object
XmlNode TimestampNode = xmlDoc.SelectSingleNode("ebay:GeteBayOfficialTimeResponse/ebay:Timestamp", nsmgr);
XmlNode AckNode = xmlDoc.SelectSingleNode("ebay:GeteBayOfficialTimeResponse/ebay:Ack", nsmgr);


Using MSXML 4:
Since the Unified Schema uses namespaces, you must set the 'SelectionNamespaces' property of the DOMDocument to the namespace used by the eBay Unified Schema API

For example,

// xmlDoc is your document with the GeteBayOfficialTime response
xmlDoc.SetProperty('SelectionNamespaces', 'xmlns:ebay="urn:ebay:apis:eBLBaseComponents"')
// let's get Timestamp node
xmlNode TimestampNode = xmlDoc.SelectSingleNode('ebay:GeteBayOfficialTimeResponse/ebay:Timestamp')

 

How well did this answer your question?
Answers others found helpful

Got thoughts? Click the feedback button – your insights help us improve!