0

I have an object that spits out this if i run this code:

print_r($xml->config->Exported->stats->children() );

SimpleXMLElement Object
(
    [Stat] => Array
        (
            [0] => SimpleXMLElement Object
                (
                    [@attributes] => Array
                        (
                            [Name] => Name
                            [abrev] => 
                            [format] => 2
                        )
                )
            [1] => SimpleXMLElement Object
                (
                    [@attributes] => Array
                        (
                            [Name] => Hands
                            [abrev] => H:
                            [format] => 0
                        )
                )

            [2] => SimpleXMLElement Object
                (
                    [@attributes] => Array
                        (
                            [Name] => V.total
                            [abrev] => V:
                            [format] => 0
                        )
                )
          )

My code is:

foreach($xml->config->Exported->stats->children() as $node){

    echo $node . "<br />";
    switch ( $node->getName() )
    {
        case 'Stat':
        $stat_name = (string)$node['name'];
        echo $stat_name . " | ";
        break;
        case 'New_Line':
        echo '<hr />';
    break;
    }

Which should return something like this:

http://codepad.viper-7.com/hMvg9W

While that does work my code does not. Does the simple xml output differ from the standard xml output in the example that works, any idea how i tweak this to get it to work?

1 Answer 1

1

XML is case sensitive. "Name" and "name" are different qualified names.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.