Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

PHP XmlReader problem

  • 30-03-2007 02: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
Advertisement