easy PHP+XML parser

R

Rafal 'Raf256' Maj

Hi,
I have data like:

<?xml version="1.0" encoding="ISO-8859-2"?>
<news>
<post>
<date>10.04.2004</date>
<text>Test test test</text>
</post>
<post>
<date>15.04.2004</date>
<text>Bleh bleh bleh <a href="www.test">test</a></text>
</post>
</news>

and I want to have it in PHP as array looking like:

array(
[0] =>
array(
date => "10.04.2004"
text => "Test test test"
)
[1] =>
array (
date => "15.04.2004"
text => "Bleh bleh bleh <a href="www.test">test</a>"
)
)

problem - text can have some HTML tags, so I want to just have it all in
string.

How can I do this in PHP if I have XML data in some data.xml ?
 
A

Ashmodai

Rafal 'Raf256' Maj scribbled something along the lines of:
Hi,
I have data like:

<?xml version="1.0" encoding="ISO-8859-2"?>
<news>
<post>
<date>10.04.2004</date>
<text>Test test test</text>
</post>
<post>
<date>15.04.2004</date>
<text>Bleh bleh bleh <a href="www.test">test</a></text>
</post>
</news>

and I want to have it in PHP as array looking like:

array(
[0] =>
array(
date => "10.04.2004"
text => "Test test test"
)
[1] =>
array (
date => "15.04.2004"
text => "Bleh bleh bleh <a href="www.test">test</a>"
)
)

problem - text can have some HTML tags, so I want to just have it all in
string.

How can I do this in PHP if I have XML data in some data.xml ?

http://www.php.net/xml

Take a special look at the element handlers. That should help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top