XPath Mapping for XML Structures
In VanillaSoft, when working with XML posts that have complex structures, XPath syntax can be used to accurately extract the information you need from multiple levels of nodes.
Example 1: Extracting Contact Information
Consider the following XML structure:
<Application>
<Contact>
<FirstName>Test</FirstName>
<LastName>Tester</LastName>
</Contact>
<Info>
<FirstName>Test</FirstName>
<LastName>Tester</LastName>
</Info>
</Application>
In this example, there are two nodes containing first and last names. To specifically grab the contact's first and last names, you can use the following XPath paths as the incoming field names in VanillaSoft:
- First Name:
//Application/Contact/FirstName - Last Name:
//Application/Contact/LastName
Example 2: Extracting Phone Number Information
Consider another XML structure:
<Contact>
<PhoneNumbers>
<PhoneNumber>
<PhoneNumberValue>3030000000</PhoneNumberValue>
<PhoneNumberType>Home</PhoneNumberType>
</PhoneNumber>
<PhoneNumber>
<PhoneNumberValue>3030000000</PhoneNumberValue>
<PhoneNumberType>Mobile</PhoneNumberType>
</PhoneNumber>
</PhoneNumbers>
</Contact>
In this example, there are multiple instances of "PhoneNumberValue." To grab the home phone number, you need to look for an instance where "PhoneNumberType" has "Home" in it. Here is the appropriate XPath syntax:
- Home Phone Number:
//Contact/PhoneNumbers/PhoneNumber[PhoneNumberType = "Home"]/PhoneNumberValue
By using these XPath expressions, you can effectively map and extract specific pieces of information from complex XML structures in VanillaSoft.
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.