Date: 2008oct6
Q. How do I parse XML in my favorite language?
A.
javaScript
function parseXMLString(txt) {
var obj;
if (window.DOMParser) { // Firefox
var parser = new DOMParser();
obj = parser.parseFromString(txt,'text/xml');
}
else { // IE
obj = new ActiveXObject('Microsoft.XMLDOM');
obj.async='false';
obj.loadXML(txt);
}
return obj;
// Both Firefox and IE have different methods for loading files
}
PHP
$xml = simplexml_load_string($txt);
var_dump($xml);
Perl
use XML::Simple;
use Data::Dumper;
$xml = new XML::Simple;
$data = $xml->XMLin(txt);
print Dumper($data);
C/C++
Expat
http://expat.sourceforge.net