Jump to content

Parse XML Directly to page vs. Into an Array


denoteone

Recommended Posts

Trying to figure out what's best practice when it comes to parsing XML and echoing it into a pretty little table.

 

should I save all the data in a array and then loop through the array? Or should I just echo the data directly from the XML file?

 

Any thoughts would be welcomed. 

Trying to figure out what's best practice when it comes to parsing XML and echoing it into a pretty little table.

 

should I save all the data in a array and then loop through the array? Or should I just echo the data directly from the XML file?

 

Any thoughts would be welcomed. 

 

Like ManiacDan mentioned, XSL is the easiest and most efficient way to do this.  You can embed HTML into the XSL sheet and still use CSS to style your HTML.  If you don't want to go this route and still want to use PHP then you can use something like SimpleXML.

I should have looked into XSL before. My life just got a little easier. Thanks!

 

Next question. the XML I am outputting depends a lot on the users interaction. What I was thinking to do was based on the Users selection I would use PHP to call the raw XML file. I can then use PHP to insert the correct XSL style sheet (based on the users selection) and then echo that data to the display?

 

how does that sound?

Next question. the XML I am outputting depends a lot on the users interaction. What I was thinking to do was based on the Users selection I would use PHP to call the raw XML file. I can then use PHP to insert the correct XSL style sheet (based on the users selection) and then echo that data to the display?

 

An XSL is embedded in your XML if they ask for XML(y) then you just readfile the particular XML, the browser knows what to do once it receives it. However what kind of data does this XML hold? What's your assumption of the size this would grow to?

An XSL is embedded in your XML

Actually the xml does not have the <?xml-stylesheet href="filename.xsl" type="text/xsl"?> info in it when I pull it.

 

So I am going to have the php insert the style sheet info. then echo the XML to the page. I am testing it now.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.