steve.winter

XPath with BE_XPath()

Discussion created by steve.winter on Jan 8, 2013
Latest reply on Jan 14, 2013 by steve.winter

Hi all

 

I need to access data from a remote XML feed, which I'm trying to do using an FM script and the BE plugin.

 

At present I've got;

Set Variable[$xml; Value:BE_GetURL("http://my.url.com/xmlfeed"; ""; "username"; "password")]

 

So far so good, in the data viewier I get my variable correctrly set to the XML feed from the remote server, that looks like this:

 

<Users xmlns="http://my.url.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instanc" xsi:schemaLocation="schema.xsd">

<User>
<UserId>123</UserId>

<UserRole>TRADER</UserRole>

<Title>Mr.</Title>

<Firstname>Some</Firstname>

<Surname>Person</Surname>

<CompanyName>A Company</CompanyName>

<TradingName>A Company</TradingName>

<Address>
<AddressLine1>123 Some Street</AddressLine1>

<Town>London</Town>

<Postcode>W1 2SQL</Postcode>

<Country>United Kingdom</Country>

<Telephone>908090808</Telephone>

<Mobile>0808080808</Mobile>

</Address>

<ProductCategories>
<Category>Clothing and Footwear</Category>

<Category>Fashion and Design</Category>

</ProductCategories>

<ExpiryDate/>

<Status>REQUESTED</Status>

</User>

</Users>

 

Now when I try to use the BE_XPath function to access data within there, I'm not getting anywhere. I've tried;

Set Variable[$addr; Value:BE_XPath ( $xml; "//AddressLine1" )]

which I expected to set variable $addr to 123 Some Street

 

Set Variable[$user; Value:BE_XPath ( $xml; "Users/User" )]

from which I expected $user to end up containing the above XML block for the user (so pretty much all of it)

 

Set Variable[$users; Value:BE_XPathAll ( $xml; "//User" )]

which I expected would give me a list of (in this case only one) users

 

I've worked with XPath before, but only within PHP and thought I understood how it works, but maybe not...? any tips...? pointers...? suggestions...?

 

Cheers

Steve

Outcomes