Posts Tagged ‘xml’

Simple XML Parser Namespace support

October 27th, 2009

I have added support for namespaces to the parser.
What this means, you are now able to register a namspace in order to be able to parse the XML.

Also the usage of this class changed.

<?php

$xml = "http://www.protung.ro/feed/atom/"; // parse an Atom feed

// create a new object
$parser = new SimpleLargeXMLParser();
// load the XML
$parser->loadXML($xml);

// register the namespace
$parser->registerNamespace("atom", "http://www.w3.org/2005/Atom");
// this will get an array of entries
$array = $parser->parseXML("//atom:feed/atom:entry");

?>

As always, you can download the new version from here.

VN:F [1.9.22_1171]
Rating: 8.5/10 (14 votes cast)

New PHP Simple Large XML Parser version

October 2nd, 2009

I have added support for node attributes to the PHP Simple Large XML Parser class.

Now it’s possible to retrieve the structure of the XML document with the attributes of the nodes. If you choose to get the nodes also the structure of the result array will be different from the non-attribute array.

The new structure will be like this:

<?php

array('value'=> 'another node / value' ,
     'attributes'=>array('attribute name'=>'attribute value',
                    'another attribute'=>'some value',
                    'yet another attribute'=>'other value'
                    )
);

?>

In order to get the array with attributes you need to pass the 3rd parameter as true:

<?php

   SimpleLargeXMLParser::parseXML($xml, "//myFirstNode", true);

?>

You can download the new version from here.

Please [p2p type=”id” value=”180″ text=”read this post”] for more information about the functionality of the class:

VN:F [1.9.22_1171]
Rating: 10.0/10 (1 vote cast)

PHP simple large XML parser

September 6th, 2009

I needed a simple PHP script to parse large XML files fast and without huge memory consumption, so I’ve written a small class for this.

This class can be used to parse large XML files (it works with small one also) fast and with minimum of memory consumption.
It can parse any valid XML and convert it to an array. What it does not do is to get the attributes of the nodes.
If you need it, contact me and i can implement it for you if you want.

You can parse any part of the XML as it supports XPath with the same performance as parsing the entire XML (well, a little bit faster as it’s less data to parse)

» Read more: PHP simple large XML parser

VN:F [1.9.22_1171]
Rating: 10.0/10 (3 votes cast)