For the most part the xml files that i get are formatted like this
For this
Code: Select all
Session xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<ret_cd>0</ret_cd>
<ret_msg>OK</ret_msg>
<session_id>-session id</session_id>
<timestamp>2/27/2010 4:56:10 AM</timestamp>
</Session>
Code: Select all
class API_SetSession
{
function RETCD()
{
return $this->RETCD_;
}
function RETMSG()
{
return $this->RETMSG_;
}
function SESSIONID()
{
return $this->SESSIONID_;
}
function TIMESTAMP()
{
return $this->TIMESTAMP_;
}
function Fetch_XML()
{
//get the xml
function startElement($parser, $name, $attribs)
{
// nothing to do here...
}
function endElement($parser, $name)
{
global $tempvalue;
if ($name == "RET_CD")
$this->RETCD_ = $tempvalue;
if ($name == "RET_MSG")
$this->RETMSG_ = $tempvalue;
if ($name == "SESSION_ID")
$this->SESSIONID_ = $tempvalue;
if ($name == "TIMESTAMP")
$this->TIMESTAMP_ = $tempvalue;
}
function characterData($parser, $data)
{
global $tempvalue;
$tempvalue = $data;
}
}
like if the xml is like this
Code: Select all
<result>
- <rowset name="name" key="a" columns="a,b,c,d,e,f">
<row AAAA a="1" b="1" c="1" d="1" e="1" f="1" />
<row BBBB a="2" b="2" c="2" d="2" e="2" f="2" />
</result>
Recently we got a new addition to the api, but it doesnt work in a way any of the previous 2 do.
It is formatted like this
Code: Select all
<result>
<user>
<username>aaaaaaa</username>
<userid>111111</userid>
</user>
<user>
<username>bbbbbb</username>
<userid>222222</userid>
</user>
</result>
Heres what ive tried (and is not working =( )
Code: Select all
function getRefTypes()
{
return $this->RefTypes_;
}
..
function endElement($parser, $name)...
if ($name == "ROW")
{
$this->RefTypes_[] = $RefTypeData;
$RefTypeData = array();
unset($RefTypeData);
}