It is currently Mon May 21, 2012 1:34 pm

All times are UTC + 2 hours [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: How to parse/print XML document attributes
PostPosted: Wed Aug 09, 2006 3:46 pm 
Offline

Joined: Wed Aug 09, 2006 3:42 pm
Posts: 2
I have a working XML parser and now want to print some of the attributes,
I want to pull into an array the type and qualifier" attributes from "Screening":
<Screening type="developer" qualifier="home">
how can I do that ?

Here is a piece of my XML doc:
<Screenings>
<Screening type="developer" qualifier="home">
<ScreeningResults type="result" mediaType="structured" resultType="report">
<Status>YES RECORD</Status>
<Region>NC</Region>
<County>UNION</County>

Here is a piece of my parser:

function parse() {
$this->output['Message'] = '';
foreach ($this->data as $k=>$v) {
switch ($v['type']) {
case 'open': // startup a handler or whatever
if (!empty($this->handlers[$v['tag']])) {
$this->tagdata[0] = $v['tag'];
$this->tagdata[$v['tag']]++;
$this->output[$this->handlers[$v['tag']][1]][$this->tagdata[$v['tag']]] = array();
}
break;
case 'close': // close handler, call handler func if defined
if (!empty($this->handlers[$v['tag']])) {
$td = $this->tagdata[$v['tag']];
$arr = $this->output[$this->handlers[$v['tag']][1]][$this->tagdata[$v['tag']]];
$this->output[$this->handlers[$v['tag']][1]][$this->tagdata[$v['tag']]][0] = call_user_func($this->handlers[$v['tag']][0],$arr);
$this->tagdata[0] = '';
}
break;
case 'complete': // usually for actual data

if ($v['tag']=='Status') {
$this->output['Status']= $v['value'];
} else if (empty($this->tagdata[0])) {
$this->output[$v['tag']] = $v['value'];

}

if (empty($this->tagdata[0])) {
$this->output[$v['tag']] = $v['value'];
}
break;
default:
break;

}
}
}

Appreciate the help !


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 2 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to: