Question

I need to extract info from a HTTP web service which is serving XML as follows:

<results>
<parametros>
    <param name="mode">xml</param>
</parametros>
<estacions>
    <estacio id="72400" nom="Aeroport"/>
    <estacio id="79600" nom="Arenys de Mar"/>
    <estacio id="79404" nom="Badalona"/>
    ...
</estacions>
</results>

How can I get the ttribute values? For example id and nom attributes? Here's my dataconfig file, but I don't reach to see how to implement this situation.

<dataConfig>
    <dataSource type="HttpDataSource" />
    <document>
            <entity name="slashdot"
                    pk="link"
                    url=http://_host_/xmlservice/"
                    processor="XPathEntityProcessor"
                    forEach="/estacions"
                    transformer="DateFormatTransformer">
                    <field column="idestacio"       xpath="/estacio.id"   commonField="true" />
                    <field column="nomestacio"      xpath="/estacio.nom"    commonField="true" />                        
            </entity>
    </document>
</dataConfig> 
Was it helpful?

Solution

See here how you can use JavaScript transformer to manipulate values extracted with XPath.

OTHER TIPS

The xpath for retrieving the attributes would be:

<field column="idestacio" xpath="/estacions/estacio/@id" commonField="true" />

A good tutorial for xpath is: http://zvon.org/comp/r/tut-XPath_1.html#Pages~Attributes

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top