easy PHP+XML parser

Discussion in 'XML' started by Rafal 'Raf256' Maj, Apr 15, 2004.

  1. 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 ,"----------"
     
    Rafal 'Raf256' Maj, Apr 15, 2004
    #1
    1. Advertising

  2. Rafal 'Raf256' Maj

    Ashmodai Guest

    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/
     
    Ashmodai, Apr 15, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rajive Narain
    Replies:
    0
    Views:
    1,901
    Rajive Narain
    Sep 18, 2009
  2. arne
    Replies:
    0
    Views:
    355
  3. Erik Wasser
    Replies:
    5
    Views:
    465
    Peter J. Holzer
    Mar 5, 2006
  4. Sean
    Replies:
    3
    Views:
    281
    robic0
    Oct 3, 2006
  5. Sean
    Replies:
    0
    Views:
    370
Loading...

Share This Page