0

I'm trying to connect to a REST web service with Drupal 7. Data is supplied via a url and I want to pull it into the D7 site to create and populate nodes. I'm using the feeds module to map the content and Web Service Client module to pull in the data but I'm unsure as to what to use as Data types to cut and split the data as I need it.

I have an address that looks like http://192.136.0.31:8080/places/getAll

The xml I get back when I use Chrome's Advanced Rest Client:

<ArrayOfAsset>
 <Asset>
    <Address1>01-02 Whatever Road</Address1>
    <Address2>Whatever Town</Address2>
    <City />
    <Country>United Kingdom</Country>
    <County>Whatevershire</County>
    <HouseNumber>0001</HouseNumber>
    <Id>01234ec0e-005456944567</Id>
    <Latitude>58.828424</Latitude>
    <LongTelephoneNumber>01543 534676</LongTelephoneNumber>
    <Longitude>126.054688</Longitude>
    <Name>Whatever the name is</Name>
    <PostCode>WH01 7PU</PostCode>
    <ShortName>Whatever</ShortName>
    <Uri></Uri>
 </Asset>
</ArrayOfAsset>

So, my question is how do I split/cut that data to return the parts I need in Clients module?

If there is anything else you need me to supply, let me know.

Update: The xml exported via the web service, although looks like xml doesn't actually format the same.

The first line is is commented out in Chrome dev tools as if chrome is putting it there itself:

<!--?xml version="1.0" encoding="utf-8"?-->

Blank head tags

<head></head>
<body>

Then straight into the code above.

ShambalaG
  • 356
  • 1
  • 7
  • 21
  • Are you asking how to get the data out of XML and map it to fields? If you're using Feeds, I'm assuming you're already using the XPath parser for it? – Oscar M. May 08 '14 at 14:10
  • I have looked into this and have been playing around with two routes. For the xPath parser settings within feeds, what is the correct syntax to use here? So Context and in this case title. What variables should go in here? – ShambalaG May 08 '14 at 14:25
  • Context is your base xpath query, '//Asset' would work, I think '/ArrayOfAsset/Asset' would too. Title would be relative to it, so if you want to use the Name field for it, 'Name' should be sufficient. – Oscar M. May 08 '14 at 14:33
  • Thanks for the reply Oscar, but using what you have suggested above it runs and I don't receive any error message but I do get the message in green instead of red that says context : There are no new nodes. – ShambalaG May 08 '14 at 16:45
  • Not that it shows above, but 'context:' and 'There are no new nodes' are two separate messages on separate lines. – ShambalaG May 08 '14 at 16:49
  • Does your XML start with tags? Somewhere in the feeds config you can turn the error logging up, have you done that and get any more useful output? – Oscar M. May 08 '14 at 17:16
  • No, it doesn't have tags. I've turned error logging up no better output. I have updated my question above with what is exported. – ShambalaG May 09 '14 at 11:31
  • Looks like your not getting well formed HTMl from your API, so Feeds can't parse it. You shouldn't have head or body tags. – Oscar M. May 09 '14 at 15:07
  • I'm going to vote to delete this post as I've gone down the JSON route now as xml is badly formatted. Thanks for your help @OscarM. – ShambalaG May 13 '14 at 09:25
  • For those wanting to know how this can be achieved in JSON, the link to the new post is http://stackoverflow.com/q/23628404/1064451 Hopefully that can get resolved soon. – ShambalaG May 14 '14 at 10:54

0 Answers0