View Single Post
  #2 (permalink)  
Old Aug 30th, 2007, 09:40
Kropotkin Kropotkin is offline
Up'n'Coming Member
Join Date: Aug 2007
Location: Bicester
Posts: 70
Thanks: 0
Thanked 0 Times in 0 Posts
Re: easiest way to parse xml

Alex

Perl supports XML with several modules. XML::Parser and libxml are the two main ones. libxml is the newer one and supports XPATH.

PHP 4 supports XML but it uses the same c library that the older Perl XML::Parser uses. PHP 5 offers better support and uses the same c library that Perl libxml uses. PHP 5 supports XPATH (I am not sure about PHP 4).

Here is some sample Perl code:

Code: Select all
 
use strict;
use XML::LibXML;

my $file = 'myfile.xml';
my $parser = XML::LibXML->new();
my $tree = $parser->parse_file($file);
my $root = $tree->getDocumentElement;#gets top element
my @species = $root->getElementsByTagName('species');
#@species is now list of all tags with name 'species'.
So: it really depends on what langauge you are already using.

As far as Javascript goes; the browsers offer an XML object which you can script with Javascript. In Internet Explorer it is the xmldom object.

XSLT (I can tell you are a beginner) is not an XML parser language. It is about transforming XML documents. A typical use is to transform XML from a database into XHTML for the web.



Justin
Reply With Quote