Why doesn’t my XML data adapter find my data?

Our Knowledge Base Has Moved

The New Page landing page for the Knowledge Base is https://product.korbyt.com/help

The new version of this specific article can be found at: https://product.korbyt.com/help/articles/8799885-why-doesnt-my-xml-data-adapter-find-my-data

Please update any of your bookmarks to the new Knowledge Base

For assistance on using the new Knowledge Base, we have a Welcome to the New Korbyt Knowledge Base guide

 

The new Korbyt Product Page also has sections for submitting feedback on system improvements, a view of our Roadmap of upcoming enhancements, and a change log of all updates.


 

 

Question

  • Why doesn’t my XML data adapter find my data?

Answer:

The XPath may not be correct.

You can use one of the on-line XPath validation tools to verify you XPath is valid and returns the data you are expecting.

For testing if the XPath is correct try using https://codebeautify.org/Xpath-Tester, or http://www.xpathtester.com/xpath.

Answer:

The XML may contain ‘namespaces

  • Name Conflicts -In XML, element names are defined by the developer. This often results in a conflict when trying to mix XML documents from different XML applications.

  • For a good example of namespace, go to this link.

If the XML ‘xmlns’ attributes they can cause your XPath to fail.

Using the sample XML below, if you wanted to get the list of company nodes you could use the XPath

/root/foo:companies

if the XML contains a default xmlns, like xmlns=”http://www.w3.org/1999/xhtml”, the XPath would need to be updated to use

/*[local-name()=’root’]/*[local-name()=’employees’]

The XPath validation tools provided with the first answer can also be used to validate XML with namespaces.

Sample XML:

<root xmlns:foo="http://www.foo.org/" xmlns:bar="http://www.bar.org">
<employees>
<employee id="1">Johnny Dapp</employee>
<employee id="2">Al Pacino</employee>
<employee id="3">Robert De Niro</employee>
<employee id="4">Kevin Spacey</employee>
<employee id="5">Denzel Washington</employee>
</employees>
<foo:companies>
<foo:company id="6">Tata Consultancy Services</foo:company>
<foo:company id="7">Wipro</foo:company>
<foo:company id="8">Infosys</foo:company>
<foo:company id="9">Microsoft</foo:company>
<foo:company id="10">IBM</foo:company>
<foo:company id="11">Apple</foo:company>
<foo:company id="12">Oracle</foo:company>
</foo:companies>
</root>

About Kevin Clark

Client Technical Support - Team Lead at RMG Networks. Been working at RMG Networks for over tens years and in technical roles for over 25 years.