witold
09-30-2005, 10:14 AM
Hi,
I'm using HDOBJ class to parse xml.
http://www.phpclasses.org/browse/package/2566.html
Here is the structure of my xml file:
<transfer>
<AdvData ID="...." ExpDate="...">
<ContactData Firm="..." City="..." Country="...">
<Email Data="sample@email.com"/>
</ContactData>
<AdvCnt Requirements="..." JobTitle="..." Description="..."/>
</AdvData>
</transfer>
Basically, I don't have a problem with accessing the first
bunch of data, but it's getting on my nerves when I try
to retrieve Email Data and all attributes from the
AdvCnt node e.g. JobTitle.
Everything is ok with
PHP Code:
foreach ($obj->AdvData as $AdvData) {
foreach($AdvData->ContactData as $ContactData) {
echo $ContactData->get_attrib("City");
}
}
but, when I use
PHP Code:
foreach ($obj->AdvData as $AdvData) {
foreach($AdvData->AdvCnt as $AdvCnt) {
echo $AdvData->$AdvCnt->get_attrib("JobTitle");
}
}
I get an error message:
Warning: Invalid argument supplied for foreach()
pointing at foreach($AdvData->AdvCnt as $AdvCnt) line.
#####
Sorry for bothering you, but if you could help solve
my problem and show me a way to access these
nodes, I'd be grateful.
Regards,
Witold
I'm using HDOBJ class to parse xml.
http://www.phpclasses.org/browse/package/2566.html
Here is the structure of my xml file:
<transfer>
<AdvData ID="...." ExpDate="...">
<ContactData Firm="..." City="..." Country="...">
<Email Data="sample@email.com"/>
</ContactData>
<AdvCnt Requirements="..." JobTitle="..." Description="..."/>
</AdvData>
</transfer>
Basically, I don't have a problem with accessing the first
bunch of data, but it's getting on my nerves when I try
to retrieve Email Data and all attributes from the
AdvCnt node e.g. JobTitle.
Everything is ok with
PHP Code:
foreach ($obj->AdvData as $AdvData) {
foreach($AdvData->ContactData as $ContactData) {
echo $ContactData->get_attrib("City");
}
}
but, when I use
PHP Code:
foreach ($obj->AdvData as $AdvData) {
foreach($AdvData->AdvCnt as $AdvCnt) {
echo $AdvData->$AdvCnt->get_attrib("JobTitle");
}
}
I get an error message:
Warning: Invalid argument supplied for foreach()
pointing at foreach($AdvData->AdvCnt as $AdvCnt) line.
#####
Sorry for bothering you, but if you could help solve
my problem and show me a way to access these
nodes, I'd be grateful.
Regards,
Witold