[XML-SIG] XML to Object translation

Lars Marius Garshol larsga@garshol.priv.no
23 Nov 2000 13:23:08 +0100

* test e. mail
| What is the best way to map XML to objects? 

I had an idea yesterday that is not yet implemented, but which will
probably become an example in my book and probably also something that
can be downloaded and used separately.

The idea is basically that when you have an XML document of a
particular type (say RSS) you make a mapping file that describes how
to create an object structure from the file. For RSS this might look
as shown below.

<object classname="SiteSummary" >
  <field name = "title">
    rss / channel / title

  <field name = "link">
    rss / channel / link

  <field name = "description">
    rss / channel / description

  <field name = "items">
    <list elements = "rss / channel / item">
      <object classname="Item">
        <field name = "title"> title </field>
        <field name = "link"> link </field>
        <field name = "description"> description </field>


This would build from any RSS file a single root object (with title,
link and description string attributes) with a list attribute holding
objects with the title, link and description string attributes.

--Lars M.