Welcome Guest, Not a member yet? Register   Sign In
A weird XML Doc, how do I use it ?
#1

[eluser]kevinprince[/eluser]
Hey,

Im writing a simple library which returns street level addresses for UK postcodes.

The service im using is called postcode anywhere, and it was pretty easy to get it to spit out the address listing but the XML isnt XML like. Ive put an example below.

Code:
<PostcodeAnywhere Server="WS03" Version="3.0" Date="21/03/2008 17:01:36" Duration="0.016s">
<Schema Items="3">
<Field Name="id"/>
<Field Name="seq"/>
<Field Name="description"/>
</Schema>
<Data Items="44">
<Item id="4493120.00" seq="0" description="36 Woodlands Road Barry"/>
<Item id="4493121.00" seq="1" description="38 Woodlands Road Barry"/>
</Data>
</PostcodeAnywhere>

Was going to use simplexml but not sure how to deal with it like this.
#2

[eluser]esra[/eluser]
[quote author="nextgengames" date="1206140985"]Hey,

Im writing a simple library which returns street level addresses for UK postcodes.

The service im using is called postcode anywhere, and it was pretty easy to get it to spit out the address listing but the XML isnt XML like. Ive put an example below.

Code:
<PostcodeAnywhere Server="WS03" Version="3.0" Date="21/03/2008 17:01:36" Duration="0.016s">
<Schema Items="3">
<Field Name="id"/>
<Field Name="seq"/>
<Field Name="description"/>
</Schema>
<Data Items="44">
<Item id="4493120.00" seq="0" description="36 Woodlands Road Barry"/>
<Item id="4493121.00" seq="1" description="38 Woodlands Road Barry"/>
</Data>
</PostcodeAnywhere>

Was going to use simplexml but not sure how to deal with it like this.[/quote]

It seems very XML to me. PostcodeAnywhere is the root node of the tree with two tree branches--Schema and Data. I'm stuck using Domit for legacy reasons, but I believe that the author stopped development on Domit with the advent of SimpleXML because it could handle everything supported by Domit. Name=, Items=, etc. are XML element attributes.

With some indents, you can see the tree structure...

Code:
<PostcodeAnywhere Server="WS03" Version="3.0" Date="21/03/2008 17:01:36" Duration="0.016s">
    <Schema Items="3">
        <Field Name="id"/>
        <Field Name="seq"/>
        <Field Name="description"/>
    </Schema>
    <Data Items="44">
        <Item id="4493120.00" seq="0" description="36 Woodlands Road Barry"/>
        <Item id="4493121.00" seq="1" description="38 Woodlands Road Barry"/>
    </Data>
</PostcodeAnywhere>

You can relate the above to a relational database table. Think of the Field elements as the column names in a relational database table, and the Item elements as arrays of the data stored in those columns.




Theme © iAndrew 2016 - Forum software by © MyBB