XPath Mapping for XML Structures
Some XML posts can have a rather complex structure. If you have multiple levels of nodes, you can use XPath syntax to grab the information you want.
Ex:
<Application>
<Contact>
<FirstName>Test</FirstName>
<LastName>Tester</LastName>
</Contact>
<Info>
<FirstName>Test</FirstName>
<LastName>Tester</LastName>
</Info>
</Application>
As demonstrated here, two nodes contain First and last names. To grab a specific field, for example contact/firstname, we can use the following path as the incoming field name in VanillaSoft:
//Application/Contact/FirstName
//Application/Contact/LastName
Ex2:
<Contact>
<PhoneNumbers>
<PhoneNumber>
<PhoneNumberValue>3030000000</PhoneNumberValue>
<PhoneNumberType>Home</PhoneNumberType>
</PhoneNumber>
<PhoneNumber>
<PhoneNumberValue>3030000000</PhoneNumberValue>
<PhoneNumberType>Mobile</PhoneNumberType>
</PhoneNumber>
</PhoneNumbers>
</Contact>
In this example, multiple instances of “PhoneNumberValue” is present. In a case where we would like to grab the home phone number, we would need to look for an instance where the “PhoneNumberType” has “home” in it.
Here is the appropriate syntax:
//Contact/PhoneNumbers/PhoneNumber[PhoneNumberType = "Home"]/PhoneNumberValue
Was this article helpful?
Thanks for the feedback. Glad we could help!
Sorry this article didn't give you the answer you were looking for. If you'd like to let us know what was missing, unclear, or anything else that could help us improve it, please share as much or as little detail as you'd like.
In case we need to clarify anything. All feedback is reviewed, whether or not you leave your email.
We read and investigate all feedback, using it to continuously improve our knowledge base.
Thank you for your feedback. If you need further assistance, please reach out to our support team.