bullchina Posted August 27, 2006 Share Posted August 27, 2006 I tried posting this two days ago, but it never got answered... I just want to learn how to parse xml that has more than three levels of depth in php, and display the results, sorted, in a smarty template. thanks for any advice you have to offer Link to comment https://forums.phpfreaks.com/topic/18794-xml-parsing-and-smarty-templates/ Share on other sites More sharing options...
devbanana Posted August 27, 2006 Share Posted August 27, 2006 What results do you want to display? What do you want to parse the XML for? Why not simply use an XSL stylesheet to do your transformation, if that is indeed what you are doing? That's more standard than Smarty, anyway. :) Link to comment https://forums.phpfreaks.com/topic/18794-xml-parsing-and-smarty-templates/#findComment-81117 Share on other sites More sharing options...
bullchina Posted August 27, 2006 Author Share Posted August 27, 2006 well i have this xml code:[code]<?xml version="1.0" encoding="ISO-8859-1"?><projects> <project> <name>Test Project</name> <date>2006</date> <location>Barcelona, Spain</location> <description><![CDATA[<p>This is a test project description with two paragraphs</p><p>this is the second paragraph</p> ]]></description> <type>Corporate Garden</type> <info>this is a field for extra information, about the clients, the size, price, etc...</info> <directory>test</directory> <images> <image name="test.porch.jpg" title="this is image 1." /> <image name="test.firstfloor.jpg" title="this is image 2." /> <image name="test.firstfloor2.jpg" title="this is image 2." /> </images> <files> <file /> <file /> </files> <status>built</status> </project></projects>[/code]and i want to be able to display the projects (there will be a lot of them) sorted by different parameters, like by type, by date, by location, and also be able to print out image thumbnails, hyperlinks to the big images, etc... I also know very little about XSL, and i wouldn't even know where to start. I'm just learning smarty, and i have the whole rest of the site working in smarty. Link to comment https://forums.phpfreaks.com/topic/18794-xml-parsing-and-smarty-templates/#findComment-81139 Share on other sites More sharing options...
devbanana Posted August 27, 2006 Share Posted August 27, 2006 This is a classic case for XSL. All I can suggest is to parse it in XSL to get the desired output, then assign the string to Smarty.Here is a starting resource on XSLT: http://www.w3schools.com/xsl/ Link to comment https://forums.phpfreaks.com/topic/18794-xml-parsing-and-smarty-templates/#findComment-81141 Share on other sites More sharing options...
bullchina Posted August 27, 2006 Author Share Posted August 27, 2006 so I will need to learn xPath as well? How long do you think all of this will take to absorb and get up and running? thanks for your help, i really appreciate it... Link to comment https://forums.phpfreaks.com/topic/18794-xml-parsing-and-smarty-templates/#findComment-81177 Share on other sites More sharing options...
devbanana Posted August 27, 2006 Share Posted August 27, 2006 Kind of depends how fast you learn things. It can be anywhere from fairly simple to magnificently comjplicated, depending on what you need to do.XPath really isn't all that hard; it is XSLT that gets difficult. Link to comment https://forums.phpfreaks.com/topic/18794-xml-parsing-and-smarty-templates/#findComment-81184 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.