Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

lachoy (1663)


I am actually Chris Winters; I am actually living in Pittsburgh, Pennsylvania, USA; I am actually married and have three cats. (Guess what one of them is named?) I am the "OpenInteract" guy, which could be good or bad.

Journal of lachoy (1663)

Wednesday January 04, 2006
01:55 PM

Parsing XML with JavaScript: anything easy?

[ #28236 ]

Now I'm looking at browser-side libraries to parse XML into a useful data structure, such as:

var doc = '<team name="Steelers" coach="Bill Cowher">' +
          '  <player>' +
          '    <position>Wide receiver</position>' +
          '    <name>Hines Ward</name>' +
          '  </player>' +
          '  <player>' +
          '    <position>Running back</position>' +
          '    <name>Jerome Bettis</name>' +
          '  </player>' +
var parsed = someParseMethod( doc );
is(, "Steelers" );
is(, "Bill Cowher" );
is( parsed.player[0].position, "Wide receiver" );
is( parsed.player[0].name, "Hines Ward" );
is( parsed.player[1].position, "Running back" );
is( parsed.player[1].name, "Jerome Bettis" );

And I seem to be coming up short: every library wants to parse an XML document into a W3C DOM or some sort of DOM facsimile. Yuck. Why deal with all those methods when you've got dynamic properties?

I figured this was a gimme since so many people are working with XML on the client these days. (Or are they?) So is there a library out there that does this basic thing?

Posted from; read original

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.