[eluser]Yorick Peterse[/eluser]
[quote author="nubianxp" date="1241452674"][quote author="Yorick Peterse" date="1241451909"]
Because the DOM is built in into PHP, so why make an library for it that already exists ?[/quote]
eh? i really didn't know that, guess that shows how noob i am about PHP... :lol:
thank you for that info![/quote]
Haha, it's really easy to use, you can parse HTML, XML etc
Working with the DOM is really simple (in this case we use an XML file):
Initialize it:
Code:
$DOM = new DOMDocument();
Load a file
Code:
$DOM->load("yourfile.xml");
Get a certain XML element with the name 'template_info'
Code:
$template_info = $DOM->getElementsByTagName("template_info");
Loop through each item
Code:
foreach($template_info as $template_infos) {
//De auteur
$author = $template_infos->getElementsByTagName('author');
$author = $author->item(0)->nodeValue;
//De naam van het thema
$name = $template_infos->getElementsByTagName('name');
$name = $name->item(0)->nodeValue;
//De website van de eigenaar van het thema
$website = $template_infos->getElementsByTagName('website');
$website = $website->item(0)->nodeValue;
//De copyrights
$copyright = $template_infos->getElementsByTagName('copyright');
$copyright = $copyright->item(0)->nodeValue;
//De licentie van het thema
$license = $template_infos->getElementsByTagName('license');
$license = $license ->item(0)->nodeValue;
//De beschrijving
$desc = $template_infos->getElementsByTagName('description');
$desc = $desc ->item(0)->nodeValue;
}
I used that code to parse an .xml file which would contain info about a template