Hi Jochem,
Thanks for your reply
>>
>> <?xml version="1.0" encoding="UTF-8"?>
>> <?ypsilon RNGSchema="fareResponse.rnc" type="compact"?>
JM> I'm fairly certain that this 'ypsilon' tag is going to cause a
JM> problem - although that's just a guess, it's based on the 'knowledge'
JM> that a valid XML document *must* have only 1 root element
JM> (which would be 'fareResponse' in this case).
That makes sense when I think about it.
JM> do as Roman says and post the simpleXML code you have so far.
I have done very little with Simple XML as I can't even get anything back out of
it. I have found the examples very confusing and I am obviously missing the
point of SimpleXML as it is obvious others are getting it to work.
$file = "test.xml";
$data = simplexml_load_file($file);
var_dump($data);
Produces the following
object(SimpleXMLElement)#1 (5) {
["@attributes"]=>
array(2) {
["cntTarifs"]=>
string(3) "122"
["offset"]=>
string(1) "0"
}
["fares"]=>
object(SimpleXMLElement)#2 (1) {
["fare"]=>
array(2) {
[0]=>
object(SimpleXMLElement)#6 (2) {
["@attributes"]=>
array(11) {
["fareId"]=>
string(8) "11429927"
["fareType"]=>
string(3) "PUB"
["checked"]=>
string(5) "false"
["class"]=>
string(1) "V"
["depApt"]=>
string(3) "SYD"
["dstApt"]=>
string(3) "LON"
["paxType"]=>
string(3) "ADT"
["vcr"]=>
string(2) "OS"
["cos"]=>
string(1) "E"
["yyFare"]=>
string(5) "false"
["avail"]=>
string(5) "false"
}
["fareBases"]=>
object(SimpleXMLElement)#8 (1) {
["fareBase"]=>
array(3) {
[0]=>
string(5) "VLOX2"
[1]=>
string(5) "VLOX2"
[2]=>
string(5) "VLOX2"
}
}
}
[1]=>
object(SimpleXMLElement)#7 (2) {
["@attributes"]=>
array(11) {
["fareId"]=>
string(8) "11429924"
["fareType"]=>
string(3) "PUB"
["checked"]=>
string(5) "false"
["class"]=>
string(1) "M"
["depApt"]=>
string(3) "SYD"
["dstApt"]=>
string(3) "LON"
["paxType"]=>
string(3) "ADT"
["vcr"]=>
string(2) "OS"
["cos"]=>
string(1) "E"
["yyFare"]=>
string(5) "false"
["avail"]=>
string(5) "false"
}
["fareBases"]=>
object(SimpleXMLElement)#9 (1) {
["fareBase"]=>
array(3) {
[0]=>
string(5) "MLOW2"
[1]=>
string(5) "MLOW2"
[2]=>
string(5) "MLOW2"
}
}
}
}
}
["tarifs"]=>
object(SimpleXMLElement)#3 (2) {
["@attributes"]=>
array(1) {
["currency"]=>
string(3) "USD"
}
["tarif"]=>
array(2) {
[0]=>
object(SimpleXMLElement)#10 (2) {
["@attributes"]=>
array(9) {
["tarifId"]=>
string(8) "11429927"
["adtBuy"]=>
string(6) "675.07"
["adtSell"]=>
string(6) "675.07"
["chdBuy"]=>
string(6) "675.07"
["chdSell"]=>
string(6) "675.07"
["infBuy"]=>
string(6) "675.07"
["infSell"]=>
string(6) "675.07"
["topCar"]=>
string(5) "false"
["topHotel"]=>
string(5) "false"
}
["fareXRefs"]=>
object(SimpleXMLElement)#12 (1) {
["fareXRef"]=>
string(8) "11429927"
}
}
[1]=>
object(SimpleXMLElement)#11 (2) {
["@attributes"]=>
array(9) {
["tarifId"]=>
string(8) "11429926"
["adtBuy"]=>
string(6) "714.83"
["adtSell"]=>
string(6) "714.83"
["chdBuy"]=>
string(6) "714.83"
["chdSell"]=>
string(6) "714.83"
["infBuy"]=>
string(6) "714.83"
["infSell"]=>
string(6) "714.83"
["topCar"]=>
string(5) "false"
["topHotel"]=>
string(5) "false"
}
["fareXRefs"]=>
object(SimpleXMLElement)#13 (1) {
["fareXRef"]=>
string(8) "11429926"
}
}
}
}
["taxes"]=>
object(SimpleXMLElement)#4 (2) {
["@attributes"]=>
array(1) {
["currency"]=>
string(3) "USD"
}
["tax"]=>
string(6) "201.52"
}
["vcrSummary"]=>
object(SimpleXMLElement)#5 (1) {
["vcr"]=>
array(2) {
[0]=>
string(2) "AA"
[1]=>
string(2) "PR"
}
}
}
So I can clearly see the data I want is there. However I have tried the
following
foreach ($data->fares as $fares)
{
print "{$fares->fares} \n";
}
And that just produces a blank line. It is obvious to me that I am not on the
right track.
Regards
Richard Luckhurst
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php