Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    May 2008
    Posts
    446
    Thanks
    23
    Thanked 5 Times in 5 Posts

    simpleXML loop missing first and last node

    I am running a foreach loop that goes through a standard array of string values. These values are used to search xml nodes with simpleXML and get the matching node for processing.

    For the most part my loop is a success. Only the first and last nodes being searched from the array are not getting found. I know that it is strictly the first and last values of the array for that by trading values in the array will cause the value that wasnt last or first but found before is now not being found when put first or last in the array.

    Here is my code:

    PHP Code:

    $inputArr 
    explode(',',$requiredNode);
        
    $customerNode $apiXML->customer;
        foreach(
    $inputArr as $input)
        {
            echo 
    'input: '.$input.'<br />';
            
    $childNode $customerNode->$input;
            echo 
    'child: '.$childNode.'<br />';
            
    $nodeArr[] = array($childNode->getName(), $childNode$childNode['value'], $childNode['readonly']);
        } 
    $requiredNode - node in xml that has string of multiple values separated by a comma.
    $input - is getting all the info I expect when running an echo
    $childNode - works fine except the first and last index in the loop, it returns empty in those cases (the values being search are in the xml file, I made sure of that and it can be found when not in the first or last index of $inputArr)

    Appreciate any help with this

  • #2
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,330
    Thanks
    23
    Thanked 616 Times in 615 Posts
    Is there anyway you can post the xml or if huge a part of it?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •