I am trying to get elements in a dom object to display and manipulate however i cant seem to get them all out:

This is the feed:

<TransactionList>
 <TransactionID>507821041</TransactionID> 
 <TransactionDate>2012-03-12T13:23:00+00:00</TransactionDate>
 <MerchantID>547</MerchantID>
 <MerchantName>The High Street Web</MerchantName>
 <ProgrammeID>1865</ProgrammeID>
 <ProgrammeName>THE HIGHSTREET WEB</ProgrammeName>
 <TrackingReference>{CLICKID}</TrackingReference>
 <IPAddress>82.34.245.167   </IPAddress>
 <SaleValue>0.0000</SaleValue>
 <SaleCommission>0.0400</SaleCommission> <LeadCommission>0.0000</LeadCommission>
</TransactionList>

However i am trying to get more than 1 tag but i cant seem to get it right.
This is my code:

<?php

$dom = new DomDocument;
$dom -> load ( "http://xyz.com" );
$tracking = $dom -> getElementsByTagName( "TrackingReference" );
//$com = $dom -> getElementsByTagName( "SaleCommission" );
$c1 = 0;
foreach( $tracking as $code )
	{
	#echo $code -> textContent.'<br>';
	$tcode = $code -> textContent;
	$tcom = $com -> textContent;
	//$com = $dom -> getElementsByTagName( "SaleCommission" );
	if ($tcode !="")
		{
		$remove_it = '{CLICKID}';
		$tcode = str_replace($remove_it, "", $tcode);
		echo $tcode.' VALUE '. $com .'<br>';
		$c1 ++;
		}
	}
echo 'Total Count: '.$c1;
?>

Please can someone help and tell me where im going wrong!

    When posting PHP code, please use the board's [noparse]

    ..

    [/noparse] bbcode tags as they make your code much easier to read and analyze.

    gotornot;10999965 wrote:

    However i am trying to get more than 1 tag but i cant seem to get it right.

    What do you mean "more than 1 tag" ? Can you elaborate on what it is you're trying to do?

      Sorry about that.

      What i am looking to do is take the commision value as well from th elements and add it per line just teh same as the coe element.
      I am trying to assign it to avariable so i can manipulate it as need be.

        Note that, as hinted by the name of the method ("getElementsByTagName"), and also by the way you're using the return value from [font=monospace]getElementsByTagName("TrackingReference")[/font] ("foreach(...)"), getElementsByTagName returns is a list of nodes; that list comes with a method for retrieving a specific single node.

          ok that reply has got me confused could you elaborate or show me where im going wrong?

            Alpha, Bravo, Charlie, Delta
            GetStuffCalled("Alpha")
            returns a list containing {Alpha}

            Alpha, Alpha, Bravo, Alpha,
            GetStuffCalled("Alpha")
            returns a list containing {Alpha, Alpha, Alpha}

            In the first case, you have one list element, thus for example THELIST->item(0). Or, you can foreach over the list, which would mean one iteration

            In the second case you can ->item(0), ->item(1), ->item(2) or foreach over the list which would mean three iteratiosn

            But, if you want something entirely different, say NOT TrackingReference but rather Comissions, then perhaps you'd instead try to get stuff called "Comission".

              Write a Reply...