Find the answer to your question
Advanced Search
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
- SetNotificationPreferences returned Success, but I'm not receiving any notifications, and GetNotificationPreferences shows my ApplicationURL as 'http://dummy.com'
- PaymentMethods must be contiguous within the XML for AddItem, RelistItem, and ReviseItem
- API Call returns an 'XML Error Text' error
- Error 20401 - Legacy format error
- Error 10012 - Invalid value for header