Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

PHP XmlReader problem

  • 30-03-2007 03:32PM
    #1
    Closed Accounts Posts: 23


    I've been toying around with a simple php script that uses the xmlreader function to print out various things from an xml file, by placing different things inside the printf statements in the while loop, like so:
    <?php
    $xml = new XMLReader();
    $xml->open("filename.xml");
    while($xml->read())
    {
    printf($xml->name."\n");
    printf($xml->depth."\n");
    printf($xml->value."\n");

    }
    ?>

    However, when i use the xml->name function, to print the name of the nodes, it prints the name of the node, followed by either usually #text or #comment.
    The actual xml looks like this
    <product_type>Album</product_type>
    <total_duration>01:10:28</total_duration>
    <total_components>1</total_components>

    While a sample output(with the other 2 printf statements commented out) for my code would look like this:
    product_type #text product_type #text
    total_duration #text total_duration #text
    total_components #text total_components #text

    Does anybody know how to fix this?


Advertisement