Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > anyone experienced with parsing xml using php?

anyone experienced with parsing xml using php?
Thread Tools
Dedicated MacNNer
Join Date: Jan 2001
Location: Boulder, CO, USA
Status: Offline
Reply With Quote
Jan 8, 2004, 02:58 PM
 
I'll probably figure out a work-around by the time I get a response, but it's possible I'm going about this in a non-optimal way anyway, so ...

The deal is I'm using xml to structure and provide meta-data for elements of webpage content. The elements are supposed to be independently usable in different places. So I want to make a standard header, keep it in one spot, and it'll look something like this:

Code:
<element name='header'> <div> blah blah blah ... straight html ... <?php blah blah blah ... ?> <?element name='someotherelement' ?> </div> </element>
The element tags are an xml container. Everything inside the element tags, however, I want to be treated as a literal and not parsed as XML. After some tranformations (running embedded php, expanding embedded elements ... ) it'll all just be sent to the browser as-is.

I'm using PHP's expat parser and I haven't found a nice way to do that. The parser analyzes all the internal html tags like <b> and <div> ... For now I just want the name of the element to be the dictionary key for the code inside the element. It's looking like it would be easier to just parse the file "by hand" ... with my own string manipulation code. But I'd rather not.

Make any sense at all? Any suggestions?

TIA.
     
Dedicated MacNNer
Join Date: Nov 2003
Location: SoCal
Status: Offline
Reply With Quote
Jan 10, 2004, 01:08 AM
 
you could trick expat by placing the php/html in CDATA envelope.

check out the explanation of CDATA here:
http://www.w3schools.com/xml/xml_cdata.asp
     
Dedicated MacNNer
Join Date: Jan 2001
Location: Boulder, CO, USA
Status: Offline
Reply With Quote
Jan 11, 2004, 03:35 PM
 
Cool, thanks. That's helpful.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 12:49 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2