Jump to content

DOM Object Help


gotornot

Recommended Posts

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.