Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

PHP XmlReader problem

Options
  • 30-03-2007 3: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