parsing an xml file in php

From: Date: Fri, 18 Apr 2003 14:42:46 +0000
Subject: parsing an xml file in php
Groups: php.general 
Request: Send a blank email to php-general+get-144408@lists.php.net to get a copy of this message
hi, i'm making a script to create a pdf from an xml file. this is my first try with xml. i thought i had got the hang of it but ... obviously not :( my xml file has the folowing structure : --cut-- <vins> <vin> <id>1</id> <name>vin1</name> </vin> <vin> <id>2</id> <name>vin2</name> </vin> ... </vins> --cut-- i have over 2000 "<vin>" elements. but when using the following code, i output the value of "count($i_ar['vin']);" i get "143" --cut-- $parser = xml_parser_create(); xml_parser_set_option($parser,XML_OPTION_SKIP_WHITE,1); xml_parser_set_option($parser,XML_OPTION_CASE_FOLDING,0); $data = implode("",file('http://sqlserver/xml/vins.xml')); //parse XML input $data into two arrays: //$i_ar - pointers to the locations of appropriate values in //$d_ar - data value array xml_parse_into_struct($parser,$data,&$d_ar,&$i_ar); for ($i=0; $i<count($i_ar['vin']); $i++) { // create the output for the PDF ... ... } --cut-- i know i'm missing something pretty basic, but can't figure out what :( Any help anyone could give me would be grately appreciated. HAND Tim

« previous php.general (#144408) next »