For full functionality of this site it is necessary to enable JavaScript.
Here are the instructions how to enable JavaScript in your web browser.

Knowledge base

Find the answer to your question

Advanced Search PView

Search terms
Search Type
Product
Category
Language
Format
SDK
Sort by
Direction

Parsing Unified Schema XML in C# or using MSXML

  • Answer ID 353
  • Published 11/07/2005 12:00 AM
  • Updated 10/20/2013 06:41 AM
  • Permalink https://ebaydts.com/eBayKBDetails?KBid=353
Product
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

Print Email This Page Delicious Digg Facebook Reddit StumbleUpon Twitter