Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-07-2013, 07:35 PM   PM User | #1
surreal5335
Regular Coder

 
Join Date: May 2008
Posts: 446
Thanks: 23
Thanked 5 Times in 5 Posts
surreal5335 is an unknown quantity at this point
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
surreal5335 is offline   Reply With Quote
Old 02-09-2013, 10:29 PM   PM User | #2
sunfighter
Senior Coder

 
Join Date: Jan 2011
Location: Missouri
Posts: 2,498
Thanks: 18
Thanked 361 Times in 360 Posts
sunfighter is on a distinguished road
Is there anyway you can post the xml or if huge a part of it?
sunfighter is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:31 PM.


Advertisement
Log in to turn off these ads.