Quantcast
Channel: Question and Answer » json
Viewing all articles
Browse latest Browse all 148

How to import JSON data from a XML element

$
0
0

I’m completely stuck with this problem for days now and I hope someone can help me out. I’m no expert in XPath so please forgive me if my question is a bit noobish:

I want to import XML data from a remote server with the Drupal Feeds & XML Xpath parser module. The Feeds module has to interact with an API that outputs the data in a XML format where the actual content is in JSON format. Here’s an example of the XML file:

<serverResponse>
  <status statusCode="0">OK</status>
    <messages>
      <user/>
      <tech/>
      <alert header="_*Alert*_"/>
    </messages>
  <content>
    {"appointmentSet":[{"appts":[]}],"bookingAllowed":false,"maxBookAheadPeriod":25}
  </content>
</serverResponse>

What I try to achieve is to grab the data with the XML parser and map it to a text field. Then I want to use the drupal_json_decode function to decode the JSON data in readable text.

My XML Xpath parser settings looks like this:

XML Xpath parser settings

Also, I guess it’s mandatory to set a unique field in the mapping settings of my Node processor. But in my case I have no clue how to set this up. Because I don’t have anything unique in my XML file. Isn’t it possible to just use the title field of the node you’re using to map the data to? So I can set a (local) Drupal field as a source?


Viewing all articles
Browse latest Browse all 148

Trending Articles