By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,889 Members | 1,044 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,889 IT Pros & Developers. It's quick & easy.

Question about PHP and SimpleXML, can i use HTML tags in XML andoutput it?

P: n/a
SM
Hello,
I have a couple of XML files that represent articles. Each XML file is
unique. Meaning that overall the structure is the same but some tags
in the xml file are not in the same place or doesn't exist.

i.e.
<DOC>
<title>Book title</title>
<p>This is a paragrap</p>
<header>Header</header>
</DOC>

<DOC>
<title>Book title</title>
<image>My image</image>
<p>Paragraph 1</p>
<p>Paragraph 2</p>
<p>Paragraph 2</p>
</DOC>

I want to use PHP to transform the XML file into readable HTML tags.
I've been doing some testing with SimpleXML file and it kind of does
half of the things...
I guess my question is, how do i create a XML file with HTML tags and
then use PHP to output it.

Maybe i should change the XML file to reflect HTML tags and use
SimpleXML (or else) to go through all the tag in XML to output? Can i
use HTML tags in XML and simply output it using php?

Any ideas?

Thanks
Marco
Oct 2 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
..oO(SM)
>I have a couple of XML files that represent articles. Each XML file is
unique. Meaning that overall the structure is the same but some tags
in the xml file are not in the same place or doesn't exist.

i.e.
<DOC>
<title>Book title</title>
<p>This is a paragrap</p>
<header>Header</header>
</DOC>

<DOC>
<title>Book title</title>
<image>My image</image>
<p>Paragraph 1</p>
<p>Paragraph 2</p>
<p>Paragraph 2</p>
</DOC>

I want to use PHP to transform the XML file into readable HTML tags.
I've been doing some testing with SimpleXML file and it kind of does
half of the things...
I guess my question is, how do i create a XML file with HTML tags and
then use PHP to output it.

Maybe i should change the XML file to reflect HTML tags and use
SimpleXML (or else) to go through all the tag in XML to output? Can i
use HTML tags in XML and simply output it using php?
Have a look at XSL/XSLT. It can be used to transform one XML language
into another, for example your article XML into HTML.

Micha
Oct 3 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.