Will this sufficient?

<pre>SimpleXMLElement Object
(
    [behaviorPrefix] => SimpleXMLElement Object
        (
        )

[behaviorSuffix] => Behavior
[valueObjectPrefix] => SimpleXMLElement Object
    (
    )

[valueObjectSuffix] => SimpleXMLElement Object
    (
    )

[package] => Array
    (
        [0] => SimpleXMLElement Object
            (
                [name] => com
            )

        [1] => SimpleXMLElement Object
            (
                [name] => com.aaa
            )

        [2] => SimpleXMLElement Object
            (
                [name] => com.aaa.bbb
            )

        [3] => SimpleXMLElement Object
            (
                [name] => com.aaa.bbb.ccc
            )

        [4] => SimpleXMLElement Object
            (
                [name] => com.aaa.bbb.ccc.dddd
            )

        [5] => SimpleXMLElement Object
            (
                [name] => com.aaa.bbb.ccc.ddd.eee
                [class] => Array
                    (
                        [0] => SimpleXMLElement Object
                            (
                                [name] => OrganizationName
                                [javaDoc] => /** */
                                [parentClass] => com.vendor.bd.baseBC.CBClass
                                [isAbstract] => false
                                [rdbPhysicalName] => ORG_NAM
                                [WherePrefix] => SimpleXMLElement Object
                                    (
                                    )

                                [DSN] => SampleDSN
                                [override] => SimpleXMLElement Object
                                    (
                                    )

                                [persistentType] => oracle8
                                [LockStrategy] => none
                                [attribute] => Array
                                    (
                                        [0] => SimpleXMLElement Object
                                            (
                                                [name] => organizationName
                                                [javaDoc] => /** */
                                                [javaType] => java.lang.String
                                                [rdbPhysicalName] => ORG_NAME
                                                [rdbLogicalType] => varchar
                                                [rdbSize] => 256
                                                [rdbDigits] => SimpleXMLElement Object
                                                    (
                                                    )

       

    How about:

    foreach($xml->package->class as $class)
    {
       echo $class->name . "<br />\n"; // just echo for now to see if it works
    }
    

      OK, I tried that and this is what I got:

      Warning: Invalid argument supplied for foreach() in C:\exampxml.php on line 9

        OK, I'm guessing here, but maybe you can use xpath() something like this (it's difficult without knowing what the source XML actually looks like):

        foreach($xml->xpath('/package/class/name/' as $name)
        {
           echo $name . "<br />\n";
        }
        

          NogDog,

          Thanks for all of your help so far...you have really gone above and beyond and I am VERY grateful.

          I tried that but got the following error message:

          Parse error: syntax error, unexpected T_AS in C:\exampxml.php on line 14

          This is the line containing the foreach statement.

          I have attached a small part of the XML file. The whole file is rather large. I had to rename it to .txt because the attach function did not like .xml

          Thanks.

          Craig

            NogDog made a typo error. It should be:

            foreach($xml->xpath('/package/class/name/') as $name)
            {
               echo $name . "<br />\n";
            }

              Laserlight, thanks for helping me with the syntax, but now I get the following error:
              Fatal error: Call to a member function xpath() on a non-object on line 3
              which is the line with the "foreach" on it.

              Thanks,

              Craig

                xpath() requires PHP 5.2.0 or later. Could that be the problem?

                  OK, I was using v5.1.2. Now I am using v5.2.3.

                  I think you guys know this already, but in case you don't I am calling the program from the command prompt in Windoze.

                  Here is the code I am using now:

                  foreach($xml->xpath('/package/class/name/') as $name) 
                  { 
                     echo $name . "<br />\n"; 
                  } 
                  

                  And I am getting the following error msg:

                  Fatal error: Call to a member function xpath() on a non-object in C:\exampxml.php on line 4

                  I am not sure if this is an imporvement or not....:bemused:

                    $xml has to be a SimpleXMLElement. What is it now?

                      Good catch again Laserlight. I had accidently commented out that line. Now, here is ALL of my code:

                      <?php
                      
                      $xml = simplexml_load_file('c:\input.xml'); 
                      foreach($xml->xpath('/package/class/name/') as $name) 
                      { 
                         echo $name . "<br />\n"; 
                      } 
                      
                      
                      ?>

                      Here are the errors I am getting:

                      Warning: SimpleXMLElement::xpath(): Invalid expression in C:\exampxml.php on line 4

                      Warning: SimpleXMLElement::xpath(): xmlXPathEval: evaluation failed in C:\exampxml.php on line 4

                      Warning: Invalid argument supplied for foreach() in C:\exampxml.php on line 4

                      Thanks.

                        Write a Reply...