Jamesking56 Posted May 27, 2009 Share Posted May 27, 2009 Can someone make an XML Parser for me because I just can't do it!I have a 'Latest News' XML file generated by my Support Center for my website, I want to integrate this into my website but I am having troubles.Here is the link for the XML file: XML FILE.It needs to have the ITEMS ONLY! not the first one as that is not an item.I want to have the page display like below: <h5><a href="LINK HERE">TITLE HERE</a></h5><p>DESCRIPTION HERE</p> Can you help me please? Link to comment Share on other sites More sharing options...
Jamesking56 Posted May 27, 2009 Author Share Posted May 27, 2009 anyone? Link to comment Share on other sites More sharing options...
Ingolme Posted May 27, 2009 Share Posted May 27, 2009 Have you looked through the XML DOM tutorial?You can apply XML DOM to PHP with the DOMDocument object: // Create an instance of a DOMDocument object$doc = new DOMDocument();// Load the file$doc->load("file.xml");// Select <item> elements$items = $doc->getElementsByTagName("item");foreach($items as $item) { // For every item get the information... $link = $item->getElementsByTagName("link")->item(0)->firstChild->nodeValue; $desc = $item->getElementsByTagName("description")->item(0)->firstChild->nodeValue; $title = $item->getElementsByTagName("title")->item(0)->firstChild->nodeValue; // ...and display it as desired echo "<h5><a href=\"{$link}\">{$title}</a></h5>"; echo "<p>{$desc}</p>";} Don't just copy the code, it might not work correctly, as I haven't tested it. Try to understand how it works. Link to comment Share on other sites More sharing options...
Jamesking56 Posted May 28, 2009 Author Share Posted May 28, 2009 Thank you so much! that worked perfectly!I didn't know about PHP XML Dom.... Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.