Oleg,

What would I need to parse:

other xml here. Start at first "<wpt lat="
.......................................
<wpt lat="42.13350000" lon="-88.97320000">
<time>2009-08-24T01:03:09Z</time>
<name>99BYTH</name>
<desc>40</desc>
<link href="http://geodashing.gpsgames.org/cgi-bin/dp.pl?dp=GD99-BYTH";>
<text>GD99-BYTH</text>
<type>text/html</type>
</link>
<sym>Geocache</sym>
<type>Geocache|Virtual Cache</type>
<extensions>
<label xmlns="http://www.topografix.com/GPX/gpx_overlay/0/3";>
<label_text>99BYTH</label_text>
<text xmlns="http://www.topografix.com/GPX/gpx_style/0/2";>
<font>
<family generic="sans-serif">
<face>Arial</face>
</family>
</font>
</text>
</label>
</extensions>
</wpt>
<wpt lat="45.84690000" lon="-88.47240000">
<time>2009-08-24T01:03:09Z</time>
<name>99BYYL</name>
<desc>120 wood</desc>
<link href="http://geodashing.gpsgames.org/cgi-bin/dp.pl?dp=GD99-BYYL";>
<text>GD99-BYYL</text>
<type>text/html</type>
</link>
<sym>Geocache</sym>
<type>Geocache|Virtual Cache</type>
<extensions>
<label xmlns="http://www.topografix.com/GPX/gpx_overlay/0/3";>
<label_text>99BYYL</label_text>
<text xmlns="http://www.topografix.com/GPX/gpx_style/0/2";>
<font>
<family generic="sans-serif">
<face>Arial</face>
</family>
</font>
</text>
</label>
</extensions>
</wpt>
....................... more of the same
Other xml

To:
+-----------+------------+------+--------+
|42.13350000|-88.97320000|99BYTH|40      |
+-----------+------------+------+--------+
|45.84690000|-88.47240000|99BYYL|120 wood|
+-----------+------------+------+--------+
|           |            |      |        |

First 2 columns from: <wpt lat="42.13350000" lon="-88.97320000">
Next column from: <name>99BYYL</name>
Last column from: <desc>120 wood</desc>

I'm doing this now with a fairly complex set of verbs.

Thank you,

Tom Arneson

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Oleg Kobchenko
Sent: Friday, September 04, 2009 17:07
To: Programming forum
Subject: [Jprogramming] x2j (XML to J) - innovative declarative way to parse
XML

x2j is an extension in the 'xml/sax' addon, which allows to
compactly describe XML parsing in a declarative way.

  http://www.jsoftware.com/jwiki/Addons/xml/sax/x2j%20Examples

I hope this will finally overcome the entry barrier for
people to take on using XML with J.

Simple things are really simple; complex are, well, possible.
Just to give you an idea. Say, covert an HTML table to J table.

  <table>
    <tr>
      <td>0 0</td><td>0 1</td><td>0 2</td><td>0 3</td>
    </tr><tr>
      <td>1 0</td><td>1 1</td><td>1 2</td><td>1 3</td>
    </tr><tr>
      <td>2 0</td><td>2 1</td><td>2 2</td><td>2 3</td>
    </tr>
  </table>

Here's all the code with definition and execution:

require 'xml/sax/x2j'
x2jclass 'px2j3'

'Items' x2jDefn
  /   :=  table             : table=: 0 0$0
  tr  :=  table=: table,row : row=: ''
  td  :=  row=: row,<y
)

    process_px2j3_ TESTX2J3
+---+---+---+---+
|0 0|0 1|0 2|0 3|
+---+---+---+---+
|1 0|1 1|1 2|1 3|
+---+---+---+---+
|2 0|2 1|2 2|2 3|
+---+---+---+---+

See the link above for more of exciting examples,
such as nested structures and attributes handling.



      
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm


----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to