Re: Better Solution needed!

From: Date: Tue, 21 Nov 2000 20:21:25 +0000
Subject: Re: Better Solution needed!
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-26510@lists.php.net to get a copy of this message
Have you thought of using a tree-based XML model instead of an event-based model? Dean. > Hola: > > Currently I am utilizing an if statement based upon count of the number > of tags parsed in xml data to determine if I have reached > the right tag. The tag <CMDTYCLASS> comes up 2 times in the same > documnet with different values. Furthermore, each CMDTYCLASS is encased > by a seperate ITEM tag: such that the xml looks like this: > > <Item> > <CmdtyClass>100</CmdtyClass> > <Weight unit="lbs">245</Weight> > <Rate currency="USD">48.49</Rate> > <Charge currency="USD">118.80</Charge> > </Item> > > <Item> > <CmdtyClass>200</CmdtyClass> > <Weight unit="lbs">245</Weight> > <Rate currency="USD">96.98</Rate> > <Charge currency="USD">237.60</Charge> > </Item> > > > The code that I use looks like this: > > > > ... (inside a function called from endElement() ) > $i++; > > $transit_time = $temp ['TRANSITTIME']; > $d_zip = $temp ['DESTINATIONZIP']; > $o_zip = $temp ['ORIGINZIP']; > $g_available = $temp ['GUARANTEEDAVAILABLE']; > > if ($i ==7) { > $cmdty_class1 = $temp ['CMDTYCLASS']; > } > $cmdty_class2 = $temp['CMDTYCLASS']; > ... > > > echo "Transit Time is: $transit_time <br>"; > echo "Destination Zip is: $d_zip <br>"; > echo "Origin Zip is: $o_zip <br>"; > echo "Guaranteed Available? $g_available <br>"; > echo "Commdity Class1 is: $cmdty_class1 <br>"; > echo "Commdity Class2 is: $cmdty_class2 <br><br> hola<br>"; > > > Although it works, this to me seems rather foolish. Is there any way in > which to varibalize(sp?) duplicate tags so that they have a unique > variable name such that I can latter manipulate them further? > > -- > Christopher C.M. Allen > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#26510) next »