Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > easy PHP+XML parser

Reply
Thread Tools

easy PHP+XML parser

 
 
Rafal 'Raf256' Maj
Guest
Posts: n/a
 
      04-15-2004
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 ?

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~l-.~~~~~~~~~~~~~~~~~~~
GG-1175498 ____| ]____,
Rafal 'Raf256' Maj X-( * )
Rafal(at)Raf256(dot)com ,"----------"
 
Reply With Quote
 
 
 
 
Ashmodai
Guest
Posts: n/a
 
      04-15-2004
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.

--
Alan Plum, WAD/WD, Mushroom Cloud Productions
http://www.mushroom-cloud.com/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting 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 Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
import parser does not import parser.py in same dir on win Joel Hedlund Python 2 11-11-2006 03:46 PM
XML Parser VS HTML Parser ZOCOR Java 11 10-05-2004 01:58 PM
XMLparser: Difference between parser.setErrorHandler() vs. parser.setContentHandler() Bernd Oninger Java 0 06-09-2004 01:26 AM
XMLparser: Difference between parser.setErrorHandler() vs. parser.setContentHandler() Bernd Oninger XML 0 06-09-2004 01:26 AM
easy to look at and easy to maintain web page menuing system. Hazzard ASP .Net 2 04-06-2004 03:51 AM



Advertisments