Re: XML: Similiar Multiple Tags With Different Data
| From: | Kjartan Mannes | Date: | Sun, 12 May 2002 21:09:53 +0000 |
| Subject: | Re: XML: Similiar Multiple Tags With Different Data | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-97252@lists.php.net to get a copy of this message | ||
Sunday, May 12, 2002, 6:39:31 PM, Sebastian A. wrote:
> Hello
> I have recently been trying to parse an XML document that has different
> content in the same tags. Here is an example:
> <LIST_ITEM>1</LIST_ITEM>
> <LIST_ITEM>2</LIST_ITEM>
> <LIST_ITEM>3</LIST_ITEM>
> ...
> I am trying to get the content from <LIST_ITEM> into an array. I want the
> content of the first <LIST_ITEM> to go into $p->ART_ID[0] and the next to go
> into $p->ART_ID[1] and so on. Here is what my Element Content Function looks
> like:
Without the rest of the code I would suspect this to work:
function elementContent($parser, $data, $attrs='') {
global $tag, $p;
$ti = sizeof( $tag ) - 1;
if ( $tag[$ti] == 'LIST_ITEM' ) {
$p->ART_ID[] = $data;
}
}
Basically when you are assigning content to a new part of the array you
don't use .= but just =
--
Kjartan <kjartan@drupal.org> (http://natrak.net/)
:: "A program is a spell cast over a computer, turning input
into error messages."
:: Drupal (www.drupal.org)