RE: [PHP] XML parsing with PHP
[snip] I need to transform some XML files and have not really done much XSLT. I am looking for recommendations on ways to parse XML via PHP. The XML files I have contain the content from our website CMS. We are switching from a proprietary CMS to Drupal and I need to transform the XML into .csv (comma separated) so I can suck the data into MySQL. Any suggestions are appreciated. Thanks![/snip] http://www.php.net/xml -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] XML parsing with PHP
Hi, I need to transform some XML files and have not really done much XSLT. I am looking for recommendations on ways to parse XML via PHP. The XML files I have contain the content from our website CMS. We are switching from a proprietary CMS to Drupal and I need to transform the XML into .csv (comma separated) so I can suck the data into MySQL. Any suggestions are appreciated. Thanks! Mari -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] xml parsing
Richard Lynch wrote: I don't think that's valid XML, because you are mixing your content with your XML tags in a way that will confuse the two... If you can FIX the XML by using the CDATA stuff, or htmlentities encoding the HTML or something, that would be best. If you are STUCK with this bogus XML, you could probably write your own parser for something this simple/small in about an hour using http://php.net/strtok and friends... On Sun, March 11, 2007 7:38 pm, Marije van Deventer wrote: I have been trying to parse this xml, and want to use it with childnodes and , but sofar due to the and and elements no luck. How can i do this in a simple way ??? Algemeen a 1-Atmosfeer a bbb ccc dd qqq Betrouwbare drukcabine I put the above xml text into an xml editor and it tests as valid, despite its raggedness, and I did manage to get it to parse with simplexml, using the following: $string = the above xml; $xml = simplexml_load_string($string); foreach($xml->Item as $item ){ trim($item->Label); echo $item->Label . ""; if(isset($item->Tekst)) { trim($item->Tekst); echo $item->Tekst . ""; } } -- _ Myron Turner http://www.room535.org http://www.bstatzero.org http://www.mturner.org/XML_PullParser/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] xml parsing
I don't think that's valid XML, because you are mixing your content with your XML tags in a way that will confuse the two... If you can FIX the XML by using the CDATA stuff, or htmlentities encoding the HTML or something, that would be best. If you are STUCK with this bogus XML, you could probably write your own parser for something this simple/small in about an hour using http://php.net/strtok and friends... On Sun, March 11, 2007 7:38 pm, Marije van Deventer wrote: > I have been trying to parse this xml, and want to use it with > childnodes and , but sofar due to the and and > elements no luck. How can i do this in a simple way ??? > > > > > Algemeen > a > > > 1-Atmosfeer > > a > bbb > ccc > dd >/>qqq /> > > > Betrouwbare drukcabine > alt="News" width="180" height="239"/> /> /> > > -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some starving artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] xml parsing
On Mon, 2007-03-12 at 01:38 +0100, Marije van Deventer wrote: > I have been trying to parse this xml, and want to use it with > childnodes and , but sofar due to the and > and elements no luck. How can i do this in a simple > way ??? You're having trouble because the person who set the content of didn't have a clue and so didn't mark up special entities. As such, the XML has now taken on a mixed structure of XML and HTML. You might have success performing the following before trying to parse: ', '', $xml ); ?> Cheers, Rob. -- .. | InterJinn Application Framework - http://www.interjinn.com | :: | An application and templating framework for PHP. Boasting | | a powerful, scalable system for accessing system services | | such as forms, properties, sessions, and caches. InterJinn | | also provides an extremely flexible architecture for | | creating re-usable components quickly and easily. | `' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] xml parsing
I have been trying to parse this xml, and want to use it with childnodes and , but sofar due to the and and elements no luck. How can i do this in a simple way ??? Algemeen a 1-Atmosfeer a bbb ccc dd qqq Betrouwbare drukcabine
Re: [PHP] XML Parsing simpleXML Arrays Question
Richard Luckhurst wrote: Hi List I have taken the advice of a number of people on the list and am back trying to write my XML parser using SimpleXML. I am having a problem and I believe the problem is my lack of understanding of arrays and simpleXML in spite of much google searching and manual reading. I would appreciate some help. The piece of XML I am parsing is as follows. I am working with a small section to see if I can get my head around it. AA PR If I use the following $file = "test.xml"; $data = simplexml_load_file($file); Just to confirm your data structure, do a var_dump($data) right here and see what the output is foreach ($data->vcrSummary as $vcrSummary) { var_dump($vcrSummary); } Then I get object(SimpleXMLElement)#5 (1) { ["vcr"]=> array(2) { [0]=> string(2) "AA" [1]=> string(2) "PR" } } Which is pretty much what I would expect as there are 2 vcr tags. If I then use $file = "test.xml"; $data = simplexml_load_file($file); right here you, at least from the example above, you need to be using $data->vcrSummary as the first parameter of the foreach loop foreach($data as $vcrSummary) { then here I would be using another foreach loop, because the $vcrSummary->vcr is an array with two indexes 0 and 1... So foreach ( $vcrSummary->vcr AS $v ) { echo "{$v}\n"; } $z = $vcrSummary->vcr; print "$z \n"; } I get 3 blank lines and then AA which is the first of the two vcr values. The examples I am looking at suggest I should have gotten both of the vcr values. Many of the examples I am looking at say to use echo instead of print, eg echo $vcrSummary->vcr; if done correctly, this should echo "Array" and maybe a warning. :( Jim Lucas and that just gives me AA and not both values that I would expect. Can anyone point me in the right direction here. Regards, Richard Luckhurst Product Development Exodus Systems - Sydney, Australia. [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] XML Parsing simpleXML Arrays Question
Hi List I have taken the advice of a number of people on the list and am back trying to write my XML parser using SimpleXML. I am having a problem and I believe the problem is my lack of understanding of arrays and simpleXML in spite of much google searching and manual reading. I would appreciate some help. The piece of XML I am parsing is as follows. I am working with a small section to see if I can get my head around it. AA PR If I use the following $file = "test.xml"; $data = simplexml_load_file($file); foreach ($data->vcrSummary as $vcrSummary) { var_dump($vcrSummary); } Then I get object(SimpleXMLElement)#5 (1) { ["vcr"]=> array(2) { [0]=> string(2) "AA" [1]=> string(2) "PR" } } Which is pretty much what I would expect as there are 2 vcr tags. If I then use $file = "test.xml"; $data = simplexml_load_file($file); foreach($data as $vcrSummary) { $z = $vcrSummary->vcr; print "$z \n"; } I get 3 blank lines and then AA which is the first of the two vcr values. The examples I am looking at suggest I should have gotten both of the vcr values. Many of the examples I am looking at say to use echo instead of print, eg echo $vcrSummary->vcr; and that just gives me AA and not both values that I would expect. Can anyone point me in the right direction here. Regards, Richard Luckhurst Product Development Exodus Systems - Sydney, Australia. [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XML Parsing, starting out.
[EMAIL PROTECTED] escribió: Hello, 1st msg here so im excited what results i will get :) Im a novice with php parsing and have been able to help myself quite well with what ive needed with xml_parse_into_struct and then echoing the fixed variable names but now im dealing with an xml document that is 1st quite large and 2nd changing gradually over time with either added data or changed information. (But not in large numbers) http://www.camelotherald.com/xml/spells-si.xml It is a spell listing for an online mmorpg. It has a "spell_list" that captures all other tags and a "spell_line" for each spell line. Within each spell line is a "spell" which has the detailed info for each spell with in the "spell_line" I could parse this by echoing the fixed variables but due to its size and the changes done over time its just to much work. This is why i come to a stop. Ive read some guides and tried some example code that should help me through this. What i hoped to get is an example with the xml i provided so i could work with it to complete the project. The example could look something like this: Header with the selected "spell_line" name ie. "Calefaction" and below that the spell info in some dummy table format. Then the next "spell_line" which is "Path of Earth" then with the spell info in some dummy table setup. Thanks for reading and i hope someone can show me the light of a real xml parse. Hi, Some months ago I was looking for some code for "loading" dynamic xml data structures my php scripts. I didn't found anything simple and flexible for my needs. I found handy the PEAR XML_beautifier tokenizer, and then I write a simple function to extract all the data with the right array structure as needed for my project. A recursive function to extract tag elements data from the tokenized arrays (attached below) Have a look at the code below. In some lines I process part of the contents from your xml sample file, so you can have something to get started, it you find handy my approach. I've attached a partial output from the data extracted by this code too. To run the code you need PEAR and XML_Beautifier and dependencies (if any, now don't remember if XML_parser is in the PEAR base install or not). Have fun, :-) Gonzalo Monzón http://www.camelotherald.com/xml/spells-si.xml";; $data = XML_tokenize($xmlsrc,True); $spell_list = _gxml_bds_extract_tag('spell_list','children',$data); // Extract spell_lines attribute data: $spell_lines_attr = _gxml_bds_extract_tag('spell_line','attribs',$spell_list,1,-1); // Extract spell_lines children data: $spell_lines_data = _gxml_bds_extract_tag('spell_line','children',$spell_list,1,-1); // Extract spell data and attributes from spell_lines: foreach($spell_lines_data as $k => $val) { $spells_attr[$k] = _gxml_bds_extract_tag('spell','attribs',$val,1,-1); $spells_data[$k] = _gxml_bds_extract_tag('spell','children',$val,1,-1); // Extract data from all spells in $k spell_line: foreach($spells_data[$k] as $k2 => $val2) { $tmp = _gxml_bds_extract_tag('level','children',$val2); $spells_data_val[$k][$k2]['level'] = $tmp[0]['data']; $tmp = _gxml_bds_extract_tag('damage_type','children',$val2); $spells_data_val[$k][$k2]['damage_type'] = $tmp[0]['data']; } } /* (A) ** */ echo $spell_lines_attr[0]['name'].""; foreach($spells_attr[0] as $k => $val) { echo $k.""; _print_bDS($val); _print_bDS($spells_data_val[0][$k]); echo ""; } /* (B) ** */ _print_bDS($spells_data[0][0]); /* ** Output: (A) ** Calefaction 0 name => Minor Shield of Magma desc => Creates a field that damages anyone who attacks the target in melee. id => 22 target => Realm level => 1 damage_type => Matter 1 name => Shield of Magma desc => Creates a field that damages anyone who attacks the target in melee. id => 23 target => Realm level => 5 damage_type => Matter 2 name => Greater Shield of Magma desc => Creates a field that damages anyone who attacks the target in melee. id => 24 target => Realm level => 9 damage_type => Matter ... ** Output: (B) ** 0 type => 1 data => depth => 3 1 type => 2 tagname => level attribs contains => 1 depth => 3 children 0 type => 1 data => 1 depth => 4 2 type => 1 data => depth => 3 3 type => 2 tagname => range attribs contains => 1 depth => 3 children 0 type => 1 data => 1000 depth => 4 4 type => 1 data => depth => 3 5 type => 2 tagname => damage attribs contains => 1 depth => 3 children 0 type => 1 data => 0.7 depth => 4 6 type => 1 data => depth => 3 7 type => 2 tagname => damage_type attribs contains => 1 depth => 3 children 0 type => 1 data => Matter depth => 4 ... */ function XML_tokenize($data,$file=False) { $p = &new XML_Beautifier_Tokenizer("iso-8859-1"); return $p->tokenize($data,$f
Re: [PHP] XML Parsing, starting out.
Mattias Thorslund wrote: [EMAIL PROTECTED] wrote: Hello, 1st msg here so im excited what results i will get :) Im a novice with php parsing and have been able to help myself quite well with what ive needed with xml_parse_into_struct and then echoing the fixed variable names but now im dealing with an xml document that is 1st quite large and 2nd changing gradually over time with either added data or changed information. (But not in large numbers) http://www.camelotherald.com/xml/spells-si.xml It is a spell listing for an online mmorpg. It has a "spell_list" that captures all other tags and a "spell_line" for each spell line. Within each spell line is a "spell" which has the detailed info for each spell with in the "spell_line" I could parse this by echoing the fixed variables but due to its size and the changes done over time its just to much work. This is why i come to a stop. Ive read some guides and tried some example code that should help me through this. What i hoped to get is an example with the xml i provided so i could work with it to complete the project. The example could look something like this: Header with the selected "spell_line" name ie. "Calefaction" and below that the spell info in some dummy table format. Then the next "spell_line" which is "Path of Earth" then with the spell info in some dummy table setup. Thanks for reading and i hope someone can show me the light of a real xml parse. The comments on the Manual page [http://www.php.net/manual/en/ref.xml.php] contain an example class that parses an XML file into an associative array. I'm using something similar myself, as it seems to be a pretty straightforward way to get an easy-to-use structure in PHP 4 without dom_xml, which isn't always available. Mattias I have been trying as i said above with the php.net examples, the sitepoint examples (which have been great to give me some view of what i need and how it functions basicly) but with no luck. I can make it easy with fixed value but the dynamic part of it is still outside my reach for now. Thanks for the examples Matt and Richard - olafurw -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XML Parsing, starting out.
[EMAIL PROTECTED] wrote: > Hello, 1st msg here so im excited what results i will get :) > > Im a novice with php parsing and have been able to help myself quite well > with what ive needed with xml_parse_into_struct and then echoing the fixed > variable names but now im dealing with an xml document that is 1st quite > large and 2nd changing gradually over time with either added data or changed > information. (But not in large numbers) > > http://www.camelotherald.com/xml/spells-si.xml > > It is a spell listing for an online mmorpg. It has a "spell_list" that > captures all other tags and a "spell_line" for each spell line. Within each > spell line is a "spell" which has the detailed info for each spell with in > the "spell_line" > > I could parse this by echoing the fixed variables but due to its size and the > changes done over time its just to much work. This is why i come to a stop. > Ive read some guides and tried some example code that should help me through > this. > > What i hoped to get is an example with the xml i provided so i could work > with it to complete the project. > > The example could look something like this: > > Header with the selected "spell_line" name ie. "Calefaction" and below that > the spell info in some dummy table format. Then the next "spell_line" which > is "Path of Earth" then with the spell info in some dummy table setup. > > Thanks for reading and i hope someone can show me the light of a real xml > parse. > The comments on the Manual page [http://www.php.net/manual/en/ref.xml.php] contain an example class that parses an XML file into an associative array. I'm using something similar myself, as it seems to be a pretty straightforward way to get an easy-to-use structure in PHP 4 without dom_xml, which isn't always available. Mattias -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XML Parsing, starting out.
On Sat, April 29, 2006 11:19 am, [EMAIL PROTECTED] wrote: > Im a novice with php parsing and have been able to help myself quite > well with what ive needed with xml_parse_into_struct and then echoing In an ideal world, you would examine other XML parsing options, such as the PEAR library. If, like me, the machine in question does not have, and is unlikely to have, anything BUT the expat library in the near future, a pointer to a function that uses expat and creates something less unwieldy than the xml_parseintostruct would be most welcome... So let me know if anybody responds off-list, please. I'll be Googling for it Monday morning myself. -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] XML Parsing, starting out.
Hello, 1st msg here so im excited what results i will get :) Im a novice with php parsing and have been able to help myself quite well with what ive needed with xml_parse_into_struct and then echoing the fixed variable names but now im dealing with an xml document that is 1st quite large and 2nd changing gradually over time with either added data or changed information. (But not in large numbers) http://www.camelotherald.com/xml/spells-si.xml It is a spell listing for an online mmorpg. It has a "spell_list" that captures all other tags and a "spell_line" for each spell line. Within each spell line is a "spell" which has the detailed info for each spell with in the "spell_line" I could parse this by echoing the fixed variables but due to its size and the changes done over time its just to much work. This is why i come to a stop. Ive read some guides and tried some example code that should help me through this. What i hoped to get is an example with the xml i provided so i could work with it to complete the project. The example could look something like this: Header with the selected "spell_line" name ie. "Calefaction" and below that the spell info in some dummy table format. Then the next "spell_line" which is "Path of Earth" then with the spell info in some dummy table setup. Thanks for reading and i hope someone can show me the light of a real xml parse. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XML parsing
On 2/9/06, Peter Lauri <[EMAIL PROTECTED]> wrote: > And the opposite way, creating XML, must be even easier. Any function that > take an array as input, and returns XML? If not, I just need to create a > recursive function that loops thru the array. If there is a standard function > I would be very happy. Once again, check those user comments. There's some excellent examples there, for two-way parsing XML files! -- Kim Christensen [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XML parsing
Peter Lauri wrote: Stupid me :) It has all I need!!! And the opposite way, creating XML, must be even easier. Any function that take an array as input, and returns XML? If not, I just need to create a recursive function that loops thru the array. If there is a standard function I would be very happy. Right now I am getting killed by the strong Thai woman that is giving me massage here in Bangkok. Foreach works here great. you can recursively go through arrays. not with standard foreach but with a small additions. if you need code let me know. i think there are also XML functions. But forgot which one it was >< greets barry -- Smileys rule (cX.x)C --o(^_^o) Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XML parsing
Stupid me :) It has all I need!!! And the opposite way, creating XML, must be even easier. Any function that take an array as input, and returns XML? If not, I just need to create a recursive function that loops thru the array. If there is a standard function I would be very happy. Right now I am getting killed by the strong Thai woman that is giving me massage here in Bangkok. Tnx -Original Message- From: "Kim Christensen"<[EMAIL PROTECTED]> Sent: 9/02/06 6:13:48 PM To: "Peter Lauri"<[EMAIL PROTECTED]> Cc: "PHP General Users" Subject: Re: [PHP] XML parsing On 2/9/06, Peter Lauri <[EMAIL PROTECTED]> wrote: > Or maybe an function that create an array from the XML: > $arr = xml_to_array($xml); > Any one who can give a really SIMPLE example of this? http://php.net/xml Have you checked the user comments? -- Kim Christensen [EMAIL PROTECTED] [Message truncated. Tap Edit->Mark for Download to get remaining portion.] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XML parsing
On 2/9/06, Peter Lauri <[EMAIL PROTECTED]> wrote: > Or maybe an function that create an array from the XML: > $arr = xml_to_array($xml); > Any one who can give a really SIMPLE example of this? http://php.net/xml Have you checked the user comments? -- Kim Christensen [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] XML parsing
Hi, When I go thru this documentation the parsing seem to be very complex. With Java this was not the case. Assume I have XML like this: $xml = 'PeterThe group'; I would like to get the value of 'from' and 'to'. My dream function would be: $from = xml_function($xml, 'from'); $to = xml_function($xml, 'to'); Or maybe an function that create an array from the XML: $arr = xml_to_array($xml); Any one who can give a really SIMPLE example of this? I would LOVE you.
[PHP] XML Parsing german special chars
I did some easy xml parsing on the last.fm[1] recent tracklist. I do read in all the tracks and output them encoded with htmlentities(). A lot of german special chars like the Ä (Ä) are transfered to strange followings of an A with any sort of available accent. But it isn't replaced by Ä The xml file does not contain any character encoding information, so how could I tell htmlentities(), there might be some character in the string, which might be a german special char. I never encountered any problems when writing htmlentities('Ähre'); or $var = 'Ähre'; htmlentities($var); but only if I take the strings out of the xml file. If I output the whole xml file all characters are shown as they are supposed to, only if i do the encoding by htmlentities() I get those weird accented letters. any suggestions how to fix this? thanks, Norbert PS: code and link to the output page can be given if needed. [1] www.last.fm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] XML Parsing
Is there a way of doing this without installing PEAR? I.e. a decent PHP Class? -Original Message- From: electroteque [mailto:[EMAIL PROTECTED] Sent: 01 April 2004 13:52 To: Nunners; [EMAIL PROTECTED] Subject: RE: [PHP] XML Parsing I found the XML_Tree class really easy to use, highly recommend it. > -Original Message- > From: Nunners [mailto:[EMAIL PROTECTED] > Sent: Thursday, April 01, 2004 10:40 PM > To: [EMAIL PROTECTED] > Subject: [PHP] XML Parsing > > > Hi Folks, > I've got an XML output from a website > (http://tawl.holiday.co.uk/EntryPoints/TopXasXML.aspx?WebsiteGUID= > E325538D-5 > B1E-4EC6-B888-35EB46418DB9) and want to display it's output on one of my > pages > I've looked at using the PHP XML Parse functions, however, I'm not certain > how to get it working Do I need something like PEAR? Or is it easier? > Can someone give me a pointer please? > Cheers > Nunners > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] XML Parsing
I found the XML_Tree class really easy to use, highly recommend it. > -Original Message- > From: Nunners [mailto:[EMAIL PROTECTED] > Sent: Thursday, April 01, 2004 10:40 PM > To: [EMAIL PROTECTED] > Subject: [PHP] XML Parsing > > > Hi Folks, > I've got an XML output from a website > (http://tawl.holiday.co.uk/EntryPoints/TopXasXML.aspx?WebsiteGUID= > E325538D-5 > B1E-4EC6-B888-35EB46418DB9) and want to display it's output on one of my > pages > I've looked at using the PHP XML Parse functions, however, I'm not certain > how to get it working Do I need something like PEAR? Or is it easier? > Can someone give me a pointer please? > Cheers > Nunners > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] XML Parsing
Hi Folks, I've got an XML output from a website (http://tawl.holiday.co.uk/EntryPoints/TopXasXML.aspx?WebsiteGUID=E325538D-5 B1E-4EC6-B888-35EB46418DB9) and want to display it's output on one of my pages I've looked at using the PHP XML Parse functions, however, I'm not certain how to get it working Do I need something like PEAR? Or is it easier? Can someone give me a pointer please? Cheers Nunners -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XML Parsing....
On Thursday 20 November 2003 08:18 am, Scott Fletcher wrote: > Hi Everyone! > > I'm having a little trouble understanding how exactly to use the XML > parser. I haven't found the right settings to set up the XML Parser's > option because of no definition of the encoding setting in the XML tags I > received. So, I'll post the script here and hope to get some feedback on > this... > > > --snip-- > $data = ""; > //Lots of XML tags goes here but is taken out for shorter > scripting > $data = " "; > //Lots of other XML tags goes here but is taken out for > shorter scripting > $data = " ]]>"; > //Lots of other XML tags goes here but is taken out for > shorter scripting > $data .= ""; > > $parser = xml_parser_create('ISO-8859-1'); > xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); > xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); > xml_parse_into_struct($parser, $data, $vals, $index); > xml_parser_free($parser); > --snip-- > > The problem here is that I have like two different XML encoding > format Do you actually have data in two diferent formats in the same XML file, or can you just change xml_parser_create to UTF-8 and be done with it? Does the XML standard even allow multiple encodings??? > > Thanks, > Scott -- Evan Nemerson [EMAIL PROTECTED] http://coeusgroup.com/en -- "The greatest mistake is to imagine that the human being is an autonomous individual. The secret freedom which you can supposedly enjoy under a despotic government is nonsense, because your thoughts are never entirely your own. Philosophers, writers, artists, even scientists, not only need encouragement and an audience, they need constant stimulation from other people. It is almost impossible to think without talking. If Defoe had really lived on a desert island, he could not have written Robinson Crusoe, nor would he have wanted to. Take away freedom of speech, and the creative faculties dry up." -George Orwell -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] XML Parsing....
Hi Everyone! I'm having a little trouble understanding how exactly to use the XML parser. I haven't found the right settings to set up the XML Parser's option because of no definition of the encoding setting in the XML tags I received. So, I'll post the script here and hope to get some feedback on this... --snip-- $data = ""; //Lots of XML tags goes here but is taken out for shorter scripting $data = " "; //Lots of other XML tags goes here but is taken out for shorter scripting $data = " ]]>"; //Lots of other XML tags goes here but is taken out for shorter scripting $data .= ""; $parser = xml_parser_create('ISO-8859-1'); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); xml_parse_into_struct($parser, $data, $vals, $index); xml_parser_free($parser); --snip-- The problem here is that I have like two different XML encoding format Thanks, Scott -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] XMl Parsing within PHP
Its $this->startElement(). That was a typo. I typed the error message instead of copying and pasting it. Sorry. -Original Message- From: Jay Blanchard [mailto:[EMAIL PROTECTED] Sent: Thursday, August 07, 2003 1:26 PM To: Donald Tyler; [EMAIL PROTECTED] Subject: RE: [PHP] XMl Parsing within PHP [snip] xml_set_element_handler($this->xml_parser, '$this->startElement', "$this->endElement"); xml_set_character_data_handler($this->xml_parser, "$this->valueHandler"); I get an error message: Warning: xml_parse(): Unable to call handler $thiss->startElement() in c:\program files\apache group\php\My_includes\Class.xmlTranslator.php on line 90 [snip] Is the handler called $thiss->startElement() or $this->startElement? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] XMl Parsing within PHP
[snip] xml_set_element_handler($this->xml_parser, '$this->startElement', "$this->endElement"); xml_set_character_data_handler($this->xml_parser, "$this->valueHandler"); I get an error message: Warning: xml_parse(): Unable to call handler $thiss->startElement() in c:\program files\apache group\php\My_includes\Class.xmlTranslator.php on line 90 [snip] Is the handler called $thiss->startElement() or $this->startElement? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] XMl Parsing within PHP
Hi, I am trying to create a Class that will parse an XML document. It all works fine as individual functions but I cant get it to work as a class. For example, when I do the following in my class: xml_set_element_handler($this->xml_parser, '$this->startElement', "$this->endElement"); xml_set_character_data_handler($this->xml_parser, "$this->valueHandler"); I get an error message: Warning: xml_parse(): Unable to call handler $thiss->startElement() in c:\program files\apache group\php\My_includes\Class.xmlTranslator.php on line 90 Now I presume this is because I am trying to call methods of my class. Does anyone know a good way around this? Thanks.
Re: [PHP] XML Parsing
On Thu, 2003-07-17 at 10:03, Doug La Farge wrote: Hello, I'm new to PHP but have been coding in Perl for over six years. I've had a steep learning curve in the last few days. My task has been to use fsockopen to pull in an XML stream, parse that XML stream, and package up that data into a complex, but usable data structure. We've been able to accomplish this in Perl but now I'm attempting to port the Perl code to PHP. The Perl code was written by Randal Schwartz (for me) but he's not interested in helping me solve the PHP problems I'm running into. I'm hoping to find someone on this list savvy in Perl and PHP, and understands complex data structures (in perl the hash refs/pointers go about four levels deep). I've included below the PHP code with three functions in question. Below each function is the Perl code I'm attempting to port. Here are some URL's that might help: http://shop.sprocketdata.com/test.php - url for the code below (which works if you copy paste) ignore the feof error- i left out the fsockopen because I know that's not where the problem is nor does this error effect the output. http://stage.holdit.com/cgi-bin/is/shipping.cgi - url for equivalent code in perl (ignore the drop-down) http://stage.holdit.com/cgi-bin/is/fetch.cgi - the data structure I'm trying to achieve in PHP http://stage.holdit.com/cgi-bin/is/is.cgi - the raw XML data structure - almost useless until parsed and probably useless to look at :-). You'll also notice at the bottom of the code I've included how the PHP XML parsed the data. It's very similar to the fetch.cgi - maybe it's different and thus causing the problem but I don't see it. if( $states == "SHIPMENT PACKAGE" ) { ^^ echo "$states\n"; //for testing should on print once! // $package_id = $Attr->{id}; // how to write this in PHP? } //This conditional is never met - QUOTE gets popped off before it returns elseif ($states = "SHIPMENT PACKAGE QUOTE") { //why does perl see QUOTE? elseif( $states == "SHIPMENT PACKAGE QUOTE" ){ ^^ echo "$states\n"; // testing // %quote = ( package_id => $package_id, id => $attr->{id} ); //Perl // $quote = array ( package_id => $package_id, id => $attr->{id} ); //PHP version of above line? } } /*Perl start_h => [ sub { my ($tagname, $attr) = @_; push @state, $tagname; if ("@state" eq "shipment package") { print "@state";#testing $package_id = $attr->{id}; } elsif ("@state" eq "shipment package quote") { %quote = ( package_id => $package_id, id => $attr->{id} ); print "@state";#testing } }, "tagname, attr"], */ // XML data //This function might work but I don't know yet as QUOTE never stays in the $state stack function characterData(&$Parser, &$Line) { global $state; $states = join (' ',$state); if ($states = "SHIPPMENT ERROR") { if( $states == "SHIPMENT ERROR" ) { ^^ $error = $Line; } elseif ($states = "SHIPMENT PACKAGE QUOTE BOXID") { elseif( $states == "SHIPMENT PACKAGE QUOTE BOXID" ) { ^^ $boxID = $Line; } elseif ($states = "SHIPMENT PACKAGE QUOTE CARRIER NAME") { elseif( $states == "SHIPMENT PACKAGE QUOTE CARRIER NAME" ) { ^^ $quote{carrier_name} = $Line; // Doubting this will work - need to fix this too } elseif ($states = "SHIPMENT PACKAGE QUOTE CARRIER CODE") { elseif( $states == "SHIPMENT PACKAGE QUOTE CARRIER CODE" ) { ^^ $quote{carrier_code} = $Line; } elseif ($states = "SHIPMENT PACKAGE QUOTE CLASS NAME") { elseif( $states == "SHIPMENT PACKAGE QUOTE CLASS NAME" ) { ^^ $quote{class_name} = $Line; } elseif ($states = "SHIPMENT PACKAGE QUOTE CLASS CODE") { elseif( $states == "SHIPMENT PACKAGE QUOTE CLASS CODE" ) { ^^ $quote{class_code} = $Line; } elseif ($states = "SHIPMENT PACKAGE QUOTE SERVICE NAME") { elseif( $states == "SHIPMENT PACKAGE QUOTE SERVICE NAME" ) { ^^ $quote{service_name} = $Line; } elseif ($states = "SHIPMENT PACKAGE QUOTE SERVICE CODE") { elseif( $states == "SHIPMENT PACKAGE QUOTE SERVICE CODE" ) { ^^ $quote{service_code} = $Line; } elseif ($states = "SHIPMENT PACKAGE QUOTE RATE AMOUNT") { elseif( $states == "SHIPMENT PACKAGE QUOTE RATE AMOUNT" ) { ^^ $quote{amount} = $Line; } } /* Perl text_h => [ sub { my ($text) = @_; if ("@state" eq "shipment error") { $error = $text; } elsif ("@state" eq "shipment package boxID") { $boxID = $text; } elsif ("@state" eq "shipment package quote carrier name") {
[PHP] XML Parsing
Hello, I'm new to PHP but have been coding in Perl for over six years. I've had a steep learning curve in the last few days. My task has been to use fsockopen to pull in an XML stream, parse that XML stream, and package up that data into a complex, but usable data structure. We've been able to accomplish this in Perl but now I'm attempting to port the Perl code to PHP. The Perl code was written by Randal Schwartz (for me) but he's not interested in helping me solve the PHP problems I'm running into. I'm hoping to find someone on this list savvy in Perl and PHP, and understands complex data structures (in perl the hash refs/pointers go about four levels deep). I've included below the PHP code with three functions in question. Below each function is the Perl code I'm attempting to port. Here are some URL's that might help: http://shop.sprocketdata.com/test.php - url for the code below (which works if you copy paste) ignore the feof error- i left out the fsockopen because I know that's not where the problem is nor does this error effect the output. http://stage.holdit.com/cgi-bin/is/shipping.cgi - url for equivalent code in perl (ignore the drop-down) http://stage.holdit.com/cgi-bin/is/fetch.cgi - the data structure I'm trying to achieve in PHP http://stage.holdit.com/cgi-bin/is/is.cgi - the raw XML data structure - almost useless until parsed and probably useless to look at :-). You'll also notice at the bottom of the code I've included how the PHP XML parsed the data. It's very similar to the fetch.cgi - maybe it's different and thus causing the problem but I don't see it. $state = array(); global $state; // these two associatative arrays will hold the data structure (I hope :-) $quote = array(); global $quote; $quotes = array(); global $quotes; //XML start element function startElement(&$Parser, &$Elem, &$Attr) { global $state; //this works array_push ($state, $Elem);//this works $states = join (' ',$state);//can't interpolate the list so must join - works if ($states = "SHIPMENT PACKAGE") { //we make it this far echo "$states\n"; //for testing should on print once! // $package_id = $Attr->{id}; // how to write this in PHP? } //This conditional is never met - QUOTE gets popped off before it returns elseif ($states = "SHIPMENT PACKAGE QUOTE") { //why does perl see QUOTE? echo "$states\n"; // testing // %quote = ( package_id => $package_id, id => $attr->{id} ); //Perl // $quote = array ( package_id => $package_id, id => $attr->{id} ); //PHP version of above line? } } /*Perl start_h => [ sub { my ($tagname, $attr) = @_; push @state, $tagname; if ("@state" eq "shipment package") { print "@state";#testing $package_id = $attr->{id}; } elsif ("@state" eq "shipment package quote") { %quote = ( package_id => $package_id, id => $attr->{id} ); print "@state";#testing } }, "tagname, attr"], */ // XML data //This function might work but I don't know yet as QUOTE never stays in the $state stack function characterData(&$Parser, &$Line) { global $state; $states = join (' ',$state); if ($states = "SHIPPMENT ERROR") { $error = $Line; } elseif ($states = "SHIPMENT PACKAGE QUOTE BOXID") { $boxID = $Line; } elseif ($states = "SHIPMENT PACKAGE QUOTE CARRIER NAME") { $quote{carrier_name} = $Line; // Doubting this will work - need to fix this too } elseif ($states = "SHIPMENT PACKAGE QUOTE CARRIER CODE") { $quote{carrier_code} = $Line; } elseif ($states = "SHIPMENT PACKAGE QUOTE CLASS NAME") { $quote{class_name} = $Line; } elseif ($states = "SHIPMENT PACKAGE QUOTE CLASS CODE") { $quote{class_code} = $Line; } elseif ($states = "SHIPMENT PACKAGE QUOTE SERVICE NAME") { $quote{service_name} = $Line; } elseif ($states = "SHIPMENT PACKAGE QUOTE SERVICE CODE") { $quote{service_code} = $Line; } elseif ($states = "SHIPMENT PACKAGE QUOTE RATE AMOUNT") { $quote{amount} = $Line; } } /* Perl text_h => [ sub { my ($text) = @_; if ("@state" eq "shipment error") { $error = $text; } elsif ("@state" eq "shipment package boxID") { $boxID = $text; } elsif ("@state" eq "shipment package quote carrier name") { $quote{carrier_name} = $text; } elsif ("@state" eq "shipment package quote carrier code") { $quote{carrier_code} = $text; } elsif ("@state" eq "shipment package quote class name") { $quote{class_name} = $text; } elsif ("@state" eq "shipment package quote class code") { $quote{class_code} = $text; } elsif ("@state" eq "shipment package quote service name") { $quote{service_name} = $text; } elsif ("@state" eq "shipment package quote service code") {
Re: [PHP] xml parsing
Change xml into a different type of xml sounds like a job for the xslt functions. Works like a charm Michael Ransburg wrote: >Hi! > >I understand that it's easily possible to parse xml documents with php. >But what about changing them? With other xml parsers, I have the xml >document in a structure (usually a tree or an array) and when I change >something in the structure I can later "write out" the structure again >into a xml file and get a changed xml file that way. Is this possible >easily with PHP too? > >Thanks >Mike > >--- >Outgoing mail is certified Virus Free. >Checked by AVG anti-virus system (http://www.grisoft.com). >Version: 6.0.394 / Virus Database: 224 - Release Date: 03.10.2002 > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] xml parsing
Hi! I understand that it's easily possible to parse xml documents with php. But what about changing them? With other xml parsers, I have the xml document in a structure (usually a tree or an array) and when I change something in the structure I can later "write out" the structure again into a xml file and get a changed xml file that way. Is this possible easily with PHP too? Thanks Mike --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.394 / Virus Database: 224 - Release Date: 03.10.2002 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] xml parsing (while loop question)
Hi, I have Marc Robards article on XML Parsing with PHP (wirelessdevnet.com).. which talks about parsing an XML FILE. My XML is from a remote server (used curl to get it back to PHP as a variable). How do I change the following while to read from variable instead of file without getting these lame "XML error: junk after document element at line 1"? while($data=fread($fp, 4096)){ if(!xml_parse($sml_parser, $data, feof($fp))){ die. } } What I tried was $data being the variable containing xml from remote host.. so I say while($data){ } which works but when it gets to the end it dies with: XML error: junk after document element at line 1 Can anybody help me? Can anybody see? Sundays on the phone with monday.. sorry beatles flashback. I am not the walrus but I'm not a newbie either.. so very sorry for this newbie-esque question. Kris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] xml parsing
Hi: To be honest, I don't feel like wading through their example to figure out what's wrong. The way they're parsing doesn't seem very efficient to me. Check this tutorial/example out: http://www.analysisandsolutions.com/code/phpxml.htm Way cleaner and straight ahead. Enjoy, --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] xml parsing
I got this example from Beginning PHP 4. Unfortunately, I cant get to wrox's site to see if there were any errata updates for this piece of code, but for the life of me, I dont know whats wrong with it. All its displaying is '-'. If anyone could direct me to where its broken, Ill be very grateful.. http://freshmeat.net/backend/fm.rdf";, "r"))) die("Cant fetch"); $item_counter = 0; $in_item_tag = 0; $fm_current_tag_state = ''; $fm_headline_data = array(); function startElementHandler($parser, $element_name, $element_attribs) { global $item_counter, $in_item_tag, $fm_current_tag_state, $fm_headline_data; if ($element_name == "ITEM") { $in_item_tag = 1; } if ($in_item_tag == 1) { $fm_curent_tag_state = $element_name; } else { $fm_current_tag_state = ''; } } function endElementHandler($parser, $element_name) { global $item_counter, $in_item_tag, $fm_current_tag_state, $fm_headline_data; $fm_current_tag_state = ''; if ($element_name == "ITEM") { $item_counter++; $in_item_tag = 0; } } function characterDataHandler($parser, $data) { global $itme_counter, $in_item_tag, $fm_current_tag_state, $fm_headline_data; if ($fm_current_tag_state == '' || $in_item_tag == 0) return; if ($fm_current_tag_state == "TITLE") $fm_headline_data[$item_counter]['title'] = $data; if ($fm_current_tag_state == "LINK") $fm_headline_data[$item_counter]['link'] = $data; if ($fm_current_tag_state == "DESCRIPTION") $fm_headline_data[$item_counter]['description'] = $data; } if (!($xml_parser = xml_parser_create())) die("Parser Problem"); xml_set_element_handler($xml_parser, "startElementHandler", "endElementHandler"); xml_set_character_data_handler($xml_parser, "characterDataHandler"); while ($data = fread($fp, 4096)) { if (!xml_parse($xml_parser, $data, feof($fp))) { break; } } xml_parser_free($xml_parser); for($i=0; $i < $item_counter; $i++) { printf("%s - %s\n", $fm_headlines_data[$i]['link'], $fm_headlines_data[$i]['title'], $fm_headlines_data[$i]['description'] ); } ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] XML Parsing Problem
Huh - I guess it could be useful. I still think this should be an option you could set with xml_parser_set_option(), or something. In case anyone is interested, I solved the problem by creating a new global variable, $previousTag. Each time my character parsing function is called, it compares the previous tag to the current tag. If they are the same, the data gets stuffed into a buffer; if they are different, the buffer is returned, cleared, and the new data stuffed into it...and $previousTag is set to the current tag. Ben On Wednesday, January 2, 2002, at 06:41 PM, Matthew Clark wrote: > well thats just the way XML parsers work, according to the parser, what > you > have there is not a single string element, you have three child elements > (the parent node being the ).. two string nodes broken up by an > entity node. In other circumstances, this behaviour can be very useful. > > Matt. > > > -Original Message- > From: Ben Gollmer [mailto:[EMAIL PROTECTED]] > Sent: 02 January 2002 23:16 > To: [EMAIL PROTECTED] > Cc: [EMAIL PROTECTED] > Subject: Re: [PHP] XML Parsing Problem > > > Ok, I can understand the predefined entity replacement. But why does it > break the string up into 3 parts? I think it should just return > "Follow-up To Critique of BeOS & Mac OS X". > > Ben > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] XML Parsing Problem
well thats just the way XML parsers work, according to the parser, what you have there is not a single string element, you have three child elements (the parent node being the ).. two string nodes broken up by an entity node. In other circumstances, this behaviour can be very useful. Matt. -Original Message- From: Ben Gollmer [mailto:[EMAIL PROTECTED]] Sent: 02 January 2002 23:16 To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: [PHP] XML Parsing Problem Ok, I can understand the predefined entity replacement. But why does it break the string up into 3 parts? I think it should just return "Follow-up To Critique of BeOS & Mac OS X". Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] XML Parsing Problem
Ok, I can understand the predefined entity replacement. But why does it break the string up into 3 parts? I think it should just return "Follow-up To Critique of BeOS & Mac OS X". Ben On Wednesday, January 2, 2002, at 02:05 PM, Matthew Clark wrote: > Hi there, > > This is not a bug.. this is expected behaviour. > > The string would be chopped up into 3 parts because you have : > > 1. a string: "Follow-up To Critique of BeOS " > 2. a predefined entity : "&" > 3. a string: "amp; Mac OS X" > > There are not actually two ampersands.. you have & followed by > amp; - > this is so that once it has been parsed you end up with & which will > display correctly in most HTML browsers. > > Note that & is a usually a predefined entity in XML and so will be > replaced with "&". > > HTH > > Matt. > > -----Original Message- > From: Ben Gollmer [mailto:[EMAIL PROTECTED]] > Sent: 01 January 2002 00:23 > To: [EMAIL PROTECTED] > Subject: [PHP] XML Parsing Problem > > > Hi all - > > I'm experimenting with PHP's XML parser for an application that maps XML > tags to MySQL database fields. > > As a test for my parsing program, I've been grabbing XML from the > Slashdot news feed (http://www.slashdot.org/slashdot.xml) and inserting > it into a database. This is very simple data - blah gets > inserted into the 'title' field, etc. However, when there are some > strange characters in the title field, the XML parser seems to choke. > > Here is an example. The title of a recent article from Slashdot looks > like this in the XML file: > > Follow-up To Critique of BeOS & Mac OS X > > Don't ask my why they have a double ampersand in there... Anyway, the > XML parser returns this as three sets of data, instead of one. The array > that I get looks like this: > > $myArray[0] = "Follow-up To Critique of BeOS " > $myArray[1] = "&" > $myArray[2] = "amp; Mac OS X" > > This is the data I get back from the parser, BEFORE putting it into the > database. I'm echoing each array field to the screen, just to make sure. > So I know it has nothing to do with MySQL. The double ampersand > shouldn't make a difference - the XML parser should not be interpreting > HTML...right? Also, I don't get an error code or error string from > xml_parse(). > > Anyone have any ideas? This is a subtle bug - in fact I had been > satisfied with my XML parsing code, and was well into the rest of my > application when I happened to notice this. > > Ben > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] XML Parsing Problem
Hi there, This is not a bug.. this is expected behaviour. The string would be chopped up into 3 parts because you have : 1. a string: "Follow-up To Critique of BeOS " 2. a predefined entity : "&" 3. a string: "amp; Mac OS X" There are not actually two ampersands.. you have & followed by amp; - this is so that once it has been parsed you end up with & which will display correctly in most HTML browsers. Note that & is a usually a predefined entity in XML and so will be replaced with "&". HTH Matt. -Original Message- From: Ben Gollmer [mailto:[EMAIL PROTECTED]] Sent: 01 January 2002 00:23 To: [EMAIL PROTECTED] Subject: [PHP] XML Parsing Problem Hi all - I'm experimenting with PHP's XML parser for an application that maps XML tags to MySQL database fields. As a test for my parsing program, I've been grabbing XML from the Slashdot news feed (http://www.slashdot.org/slashdot.xml) and inserting it into a database. This is very simple data - blah gets inserted into the 'title' field, etc. However, when there are some strange characters in the title field, the XML parser seems to choke. Here is an example. The title of a recent article from Slashdot looks like this in the XML file: Follow-up To Critique of BeOS & Mac OS X Don't ask my why they have a double ampersand in there... Anyway, the XML parser returns this as three sets of data, instead of one. The array that I get looks like this: $myArray[0] = "Follow-up To Critique of BeOS " $myArray[1] = "&" $myArray[2] = "amp; Mac OS X" This is the data I get back from the parser, BEFORE putting it into the database. I'm echoing each array field to the screen, just to make sure. So I know it has nothing to do with MySQL. The double ampersand shouldn't make a difference - the XML parser should not be interpreting HTML...right? Also, I don't get an error code or error string from xml_parse(). Anyone have any ideas? This is a subtle bug - in fact I had been satisfied with my XML parsing code, and was well into the rest of my application when I happened to notice this. Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] XML Parsing Problem
Hi all - I'm experimenting with PHP's XML parser for an application that maps XML tags to MySQL database fields. As a test for my parsing program, I've been grabbing XML from the Slashdot news feed (http://www.slashdot.org/slashdot.xml) and inserting it into a database. This is very simple data - blah gets inserted into the 'title' field, etc. However, when there are some strange characters in the title field, the XML parser seems to choke. Here is an example. The title of a recent article from Slashdot looks like this in the XML file: Follow-up To Critique of BeOS & Mac OS X Don't ask my why they have a double ampersand in there... Anyway, the XML parser returns this as three sets of data, instead of one. The array that I get looks like this: $myArray[0] = "Follow-up To Critique of BeOS " $myArray[1] = "&" $myArray[2] = "amp; Mac OS X" This is the data I get back from the parser, BEFORE putting it into the database. I'm echoing each array field to the screen, just to make sure. So I know it has nothing to do with MySQL. The double ampersand shouldn't make a difference - the XML parser should not be interpreting HTML...right? Also, I don't get an error code or error string from xml_parse(). Anyone have any ideas? This is a subtle bug - in fact I had been satisfied with my XML parsing code, and was well into the rest of my application when I happened to notice this. Ben -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] PHP & XML Parsing
> Interesting.. So to be consistent with proper XML formatting, > should the server hosting the XML file convert the & into > & ? It depends on the situation, I believe. The server that sends you XML should indeed provide you well-formed XML, which it's not doing. Probably what should happen is that the server sending the XML should urlencode URLs in the cdata elements, and then after you parse the XML file you should urldecode the URLs. I would be surprised if this hasn't been done as some standard part of XML parsing and I've just missed it in my limited use of XML parsers. > I certainly feel like I'm missing something... Although I'm a bit at > odds as to how to troubleshoot this new file. > I no longer get the errors, but I'm not getting the results I'm looking for either. I'm not sure what results you're looking for exactly, but if you put in a bunch of echo statements at various points throughout your parsing routines, you will see that none of the "if x = y" conditions are matching. Here's what I'd recommend: 1. put in a bunch of echo statements to print out your variables at different points in your parsing, just to make sure it's doing what you expect it to. Do a full audit of your characterData routine through this method, and I think it will show you where the errors are. (I did not see the exact error right away so I gave up since I do have a day job. :-) 2. keep your first eregi_replace statement, then when you're printing out the links, re-convert it with a reverse eregi_replace to turn the & back into a simple &. This will send it to the HTML browser in the format you want, I hope. I hope this is of some help. Pete. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] PHP & XML Parsing
Hello Peter, Peter Dudley wrote: > The problem is in your link URL, where you pass CGI parameters. When XML > sees the & character, it assumes it's a special character thing such as > & or ", so it's expecting a semicolon. replacing it with & fixed the XML error. Thanks! > http://cupe.ca/news/cupenews/showitem.asp?ID=2823&cl=1 > Just yesterday I discovered a program called XML Spy which you can get on a > 30-day eval from www.tucows.com. This was what pointed out the error to me > in your file. Interesting.. So to be consistent with proper XML formatting, should the server hosting the XML file convert the & into & ? > When I was using XSL last year for the first time, I had a devil of a time > figuring out how to get URLs, particularly with query strings attached, > through the XML parsers. Try using the %codes in your URLs instead of & and > other special characters; that should help, if I remember correctly. > (Similarly, building HREF tags using XSL stylesheets seemed pretty awkward, > but I'm sure I was missing some crucial tidbit of information.) I certainly feel like I'm missing something... Although I'm a bit at odds as to how to troubleshoot this new file. I no longer get the errors, but I'm not getting the results I'm looking for either. The updated script is running here: http://www.airdiv-cupe.org/portal/newsfeed_new_parser.php I've also attached the full script (since I've made some changes to it). Any additional help would be appreciated. Mike > "Mike Gifford" <[EMAIL PROTECTED]> wrote in message > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > >> Hello, >> >> In looking for a good script to parse XML files I stumbled across the > > following > >> tutorial (which looks very good): >> http://www.wirelessdevnet.com/channels/wap/features/xmlcast_php.html >> >> I have set this script up here: >> http://www.airdiv-cupe.org/portal/newsfeed_new_parser.php >> >> and I keep getting the following error (even after making a number of > > changes): > >> XML error: not well-formed at line 16 >> >> And I'm not sure how to troubleshoot this problem. >> >> I'm assuming that it is referring to line 16 on the XML file, in this > > case: > >> http://cupe.ca/xml/cupenews.rdf >> >> My parsing definitions are as follows >>$itemTitleKey = "^rdf^item^title"; >>$itemLinkKey = "^rdf^item^link"; >>$itemDescKey = "^rdf^item^description"; >> >> Any help would be appreciated. >> >> Mike http://airdiv.cupe.ca/portal/";; $sDescription = "A Portal for the Airline Division of CUPE"; $arItems = array(); $itemCount = 0; // * Start User-Defined Vars // rss url goes here $uFile ="http://cupe.ca/xml/cupenews.rdf";; // descriptions (true or false) goes here $bDesc = ""; // If it exists this should be 'true' // font goes here $uFont = "Verdana, Arial, Helvetica, sans-serif"; $uFontSize = "2"; // * End User-Defined Vars ** function startElement($parser, $name, $attrs) { global $curTag; $curTag .= "^$name"; } function endElement($parser, $name) { global $curTag; $caret_pos = strrpos($curTag,'^'); $curTag = substr($curTag,0,$caret_pos); } function characterData($parser, $data) { global $curTag; // get the Channel information first global $sTitle, $sLink, $sDescription; // $titleKey = "^RSS^CHANNEL^TITLE"; // $linkKey = "^RSS^CHANNEL^LINK"; // $descKey = "^RSS^CHANNEL^DESCRIPTION"; $titlekey = "^rdf:RDF^channel^title"; $linkkey = "^rdf:RDF^channel^link"; $desckey = "^rdf:RDF^channel^description"; if ($curTag == $titleKey) { $sTitle = $data; echo $sTitle; } elseif ($curTag == $linkKey) { $sLink = $data; echo $sLink; } elseif ($curTag == $descKey) { $sDescription = $data; } // now get the items global $arItems, $itemCount; // $itemTitleKey = "^RSS^CHANNEL^ITEM^TITLE"; // $itemLinkKey = "^RSS^CHANNEL^ITEM^LINK"; // $itemDescKey = "^RSS^CHANNEL^ITEM^DESCRIPTION"; $itemtitlekey = "^rdf:RDF^item^title"; $itemlinkkey = "^rdf:RDF^item^link"; $itemdesckey = "^rdf:RDF^item^description"; if ($curTag == $itemTitleKey) { // make new xitem $arItems[$itemCount] = new xitem(); // set new item object's properties $arItems[$itemCount]->xTitle = $data; echo $data; } elseif ($curTag == $itemLinkKey) { $arItems[$itemCount]->xLink = $data; echo $data; } elseif ($curTag == $itemDescKey) { $arItems[$itemCount]->xDescription = $data; // increment item counter $itemCount++; echo $data; } } // main loop $xml_parser = xml_parser_create(); xml_set_element_handler($xml_parser, "startElement", "endElement"); xml_set_character_data_handler($xml_parser, "characterData"); if (!($fp = fopen($uFile,"r"))) { die ("could not open RSS for input"); } while ($data = fread($fp, 4096)) { $data=eregi_replace( "&", "&",$data); echo $data; if (!xml_parse($xml_parser, $data, feof($fp))) { die(sprin
Re: [PHP] PHP & XML Parsing
Hello Fabian, This was very helpful. Thanks for letting me know about this little glitch. It almost resolves the problem that I was having. Now I no longer get xml errors. However, I'm not able to output the XML either. Any suggestions would be appreciated. The updated code is available here: http://www.airdiv-cupe.org/portal/newsfeed_new_parser.php And I've included the full script in the email (at the very bottom of this message). Thanks. Mike Fabian Raygosa wrote: > for xml you have to escape certain characters in the file, one is the > ampersand ... > - Original Message - > From: "Mike Gifford" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Friday, May 18, 2001 12:24 PM > Subject: [PHP] PHP & XML Parsing > > > >> Hello, >> >> In looking for a good script to parse XML files I stumbled across the > > following > >> tutorial (which looks very good): >> http://www.wirelessdevnet.com/channels/wap/features/xmlcast_php.html >> >> I have set this script up here: >> http://www.airdiv-cupe.org/portal/newsfeed_new_parser.php >> >> and I keep getting the following error (even after making a number of > > changes): > >> XML error: not well-formed at line 16 >> >> And I'm not sure how to troubleshoot this problem. >> >> I'm assuming that it is referring to line 16 on the XML file, in this > > case: > >> http://cupe.ca/xml/cupenews.rdf >> >> My parsing definitions are as follows >>$itemTitleKey = "^rdf^item^title"; >>$itemLinkKey = "^rdf^item^link"; >>$itemDescKey = "^rdf^item^description"; >> >> Any help would be appreciated. >> >> Mike >> -- >> Mike Gifford, OpenConcept Consulting, http://openconcept.ca >> Offering everything your organization needs for an effective web site. >> Featured Client: http://halifaxinitiative.org >> A good life is one inspired by love and guided by knowledge - B. Russell >> >> >> -- >> PHP General Mailing List (http://www.php.net/) >> To unsubscribe, e-mail: [EMAIL PROTECTED] >> For additional commands, e-mail: [EMAIL PROTECTED] >> To contact the list administrators, e-mail: [EMAIL PROTECTED] http://airdiv.cupe.ca/portal/";; $sDescription = "A Portal for the Airline Division of CUPE"; $arItems = array(); $itemCount = 0; // * Start User-Defined Vars // rss url goes here $uFile ="http://cupe.ca/xml/cupenews.rdf";; // descriptions (true or false) goes here $bDesc = ""; // If it exists this should be 'true' // font goes here $uFont = "Verdana, Arial, Helvetica, sans-serif"; $uFontSize = "2"; // * End User-Defined Vars ** function startElement($parser, $name, $attrs) { global $curTag; $curTag .= "^$name"; } function endElement($parser, $name) { global $curTag; $caret_pos = strrpos($curTag,'^'); $curTag = substr($curTag,0,$caret_pos); } function characterData($parser, $data) { global $curTag; // get the Channel information first global $sTitle, $sLink, $sDescription; // $titleKey = "^RSS^CHANNEL^TITLE"; // $linkKey = "^RSS^CHANNEL^LINK"; // $descKey = "^RSS^CHANNEL^DESCRIPTION"; $titlekey = "^rdf:RDF^channel^title"; $linkkey = "^rdf:RDF^channel^link"; $desckey = "^rdf:RDF^channel^description"; if ($curTag == $titleKey) { $sTitle = $data; echo $sTitle; } elseif ($curTag == $linkKey) { $sLink = $data; echo $sLink; } elseif ($curTag == $descKey) { $sDescription = $data; } // now get the items global $arItems, $itemCount; // $itemTitleKey = "^RSS^CHANNEL^ITEM^TITLE"; // $itemLinkKey = "^RSS^CHANNEL^ITEM^LINK"; // $itemDescKey = "^RSS^CHANNEL^ITEM^DESCRIPTION"; $itemtitlekey = "^rdf:RDF^item^title"; $itemlinkkey = "^rdf:RDF^item^link"; $itemdesckey = "^rdf:RDF^item^description"; if ($curTag == $itemTitleKey) { // make new xitem $arItems[$itemCount] = new xitem(); // set new item object's properties $arItems[$itemCount]->xTitle = $data; echo $data; } elseif ($curTag == $itemLinkKey) { $arItems[$itemCount]->xLink = $data; echo $data; } elseif ($curTag == $itemDescKey) { $arItems[$itemCount]->xDescription = $data; // increment item counter $itemCount++; echo $data; } } // main loop $xml_parser = xml_parser_create(); xml_set_element_handler($xml_parser, "startElement", "endElement"); xml_set_character_data_handler($xml_parser, "
Re: [PHP] PHP & XML Parsing
for xml you have to escape certain characters in the file, one is the ampersand ... - Original Message - From: "Mike Gifford" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, May 18, 2001 12:24 PM Subject: [PHP] PHP & XML Parsing > Hello, > > In looking for a good script to parse XML files I stumbled across the following > tutorial (which looks very good): > http://www.wirelessdevnet.com/channels/wap/features/xmlcast_php.html > > I have set this script up here: > http://www.airdiv-cupe.org/portal/newsfeed_new_parser.php > > and I keep getting the following error (even after making a number of changes): > XML error: not well-formed at line 16 > > And I'm not sure how to troubleshoot this problem. > > I'm assuming that it is referring to line 16 on the XML file, in this case: > http://cupe.ca/xml/cupenews.rdf > > My parsing definitions are as follows >$itemTitleKey = "^rdf^item^title"; >$itemLinkKey = "^rdf^item^link"; >$itemDescKey = "^rdf^item^description"; > > Any help would be appreciated. > > Mike > -- > Mike Gifford, OpenConcept Consulting, http://openconcept.ca > Offering everything your organization needs for an effective web site. > Featured Client: http://halifaxinitiative.org > A good life is one inspired by love and guided by knowledge - B. Russell > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] PHP & XML Parsing
The problem is in your link URL, where you pass CGI parameters. When XML sees the & character, it assumes it's a special character thing such as & or ", so it's expecting a semicolon. http://cupe.ca/news/cupenews/showitem.asp?ID=2823&cl=1 Just yesterday I discovered a program called XML Spy which you can get on a 30-day eval from www.tucows.com. This was what pointed out the error to me in your file. When I was using XSL last year for the first time, I had a devil of a time figuring out how to get URLs, particularly with query strings attached, through the XML parsers. Try using the %codes in your URLs instead of & and other special characters; that should help, if I remember correctly. (Similarly, building HREF tags using XSL stylesheets seemed pretty awkward, but I'm sure I was missing some crucial tidbit of information.) Pete. "Mike Gifford" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hello, > > In looking for a good script to parse XML files I stumbled across the following > tutorial (which looks very good): > http://www.wirelessdevnet.com/channels/wap/features/xmlcast_php.html > > I have set this script up here: > http://www.airdiv-cupe.org/portal/newsfeed_new_parser.php > > and I keep getting the following error (even after making a number of changes): > XML error: not well-formed at line 16 > > And I'm not sure how to troubleshoot this problem. > > I'm assuming that it is referring to line 16 on the XML file, in this case: > http://cupe.ca/xml/cupenews.rdf > > My parsing definitions are as follows >$itemTitleKey = "^rdf^item^title"; >$itemLinkKey = "^rdf^item^link"; >$itemDescKey = "^rdf^item^description"; > > Any help would be appreciated. > > Mike -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] PHP & XML Parsing
Hello, In looking for a good script to parse XML files I stumbled across the following tutorial (which looks very good): http://www.wirelessdevnet.com/channels/wap/features/xmlcast_php.html I have set this script up here: http://www.airdiv-cupe.org/portal/newsfeed_new_parser.php and I keep getting the following error (even after making a number of changes): XML error: not well-formed at line 16 And I'm not sure how to troubleshoot this problem. I'm assuming that it is referring to line 16 on the XML file, in this case: http://cupe.ca/xml/cupenews.rdf My parsing definitions are as follows $itemTitleKey = "^rdf^item^title"; $itemLinkKey = "^rdf^item^link"; $itemDescKey = "^rdf^item^description"; Any help would be appreciated. Mike -- Mike Gifford, OpenConcept Consulting, http://openconcept.ca Offering everything your organization needs for an effective web site. Featured Client: http://halifaxinitiative.org A good life is one inspired by love and guided by knowledge - B. Russell -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] XML Parsing
http://www.php.net/manual/en/ref.xml.php and http://www.phpbuilder.com/columns/joe2907.php3 great palces to get you started on XML parseing try the second one first as it jumps right into it with xpat. phpbuilder also has stuff for the DOM XML as well. - Original Message - From: "Michael Conley" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Monday, April 30, 2001 3:21 PM Subject: [PHP] XML Parsing > I am posting information to a credit card processing server. This is done > over HTTPS (with cURL) and seems to work fine. I get the response that I > want from the server, which consists of an XML doc with about 20 tags and > their corresponding values. I have gone through the mailing list and > manuals, yet I still can't seem to figure out how to get each piece of the > XML doc into their own variables. > > Here is the code I am using: > > $server = "https://www.creditcard.com";; > $path = "xmlhttps/xtrans.asp"; > $ch = curl_init(); > $requestedurl = "$server" . "/$path"; > curl_setopt($ch, CURLOPT_URL, "$requestedurl"); > curl_setopt($ch, CURLOPT_POST, 1); > curl_setopt($ch, CURLOPT_POSTFIELDS, "$xmlstring"); > curl_setopt($ch, CURLOPT_RETURNTRANSFER,0); > > curl_close ($ch); > > This replies (as it should) with an XML doc like this: > > CCDEBIT BTYPE>AUTH1010 D>PC-12347 INDICATOR>51234 >1202MichaelConley ME>PO BOX > 59AuburnCA95604 ODE>USASomebody NCY_CODE>840 ATA_0> SER_DATA_3> 6> DATA_9> > 1003509KQEGVHMGED4 _TIME>172823043020011 EXCHANGE_RATE>NO > MATCHVITAL6N VS_RESPONSE>0 > > What I need to do now is get certain parts of the return string. How do I > assign the value in the tags to the variable $approvalcode? > I also need to get several other parts of the XML string assigned to > variables so that I can use them elsewhere. I can't seem to figure out how > to do this. I know that I need to change the "CURLOPT_RETURNTRANSFER" to > "1" to allow the information to be placed somewhere other than the screen > for processing, but after that I am not sure how to do this. I have gone > through the mailing lists and through the docs online, but I'm having no > luck. > > Any help is appreciated. > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] XML Parsing
I am posting information to a credit card processing server. This is done over HTTPS (with cURL) and seems to work fine. I get the response that I want from the server, which consists of an XML doc with about 20 tags and their corresponding values. I have gone through the mailing list and manuals, yet I still can't seem to figure out how to get each piece of the XML doc into their own variables. Here is the code I am using: $server = "https://www.creditcard.com";; $path = "xmlhttps/xtrans.asp"; $ch = curl_init(); $requestedurl = "$server" . "/$path"; curl_setopt($ch, CURLOPT_URL, "$requestedurl"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "$xmlstring"); curl_setopt($ch, CURLOPT_RETURNTRANSFER,0); curl_close ($ch); This replies (as it should) with an XML doc like this: CCDEBITAUTH1010PC-12347512341202MichaelConleyPO BOX 59AuburnCA95604USASomebody840 1003509KQEGVHMGED4172823043020011NO MATCHVITAL6N0 What I need to do now is get certain parts of the return string. How do I assign the value in the tags to the variable $approvalcode? I also need to get several other parts of the XML string assigned to variables so that I can use them elsewhere. I can't seem to figure out how to do this. I know that I need to change the "CURLOPT_RETURNTRANSFER" to "1" to allow the information to be placed somewhere other than the screen for processing, but after that I am not sure how to do this. I have gone through the mailing lists and through the docs online, but I'm having no luck. Any help is appreciated. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] xml parsing
Jon A wrote: > > ... > > print ""; > break; > > ... > print ""; > break; > > - this will let it parse, but it won't do anything with the html. > > can somebody help me?? > Try this: print ''; -- Pavel a.k.a. Papi -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] xml parsing
please help me... I'm working with some simple xml parsing. in my xml document i have a tag like this: which holds the path of a picture. in the xml parser i'm trying to output it as an tag, but nothing seems to work. some of the things i have tried: case "BILLEDE": print ""; break; - this will output an error message: warning, expecting T_STRING, T_VARIABLE ETC... case "BILLEDE": print ""; break; - this will let it parse, but it won't do anything with the html. can somebody help me?? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] XML Parsing - what's wrong? - found it
-Original Message- From: Sascha Andres [mailto:[EMAIL PROTECTED]] Sent: Dienstag, 20. Februar 2001 08:25 To: [EMAIL PROTECTED] Subject: [PHP] XML Parsing - what's wrong? hi, i try to parse an xml document. but the function characterData which should process the found data is never called. startElement and endElement are called. it does not fails opening it and it gets te correct number of stories.u can have a look on the output at http://www.programmers-world.net/test/slashdot.php. thanks for any help bye sascha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] XML Parsing - what's wrong?
hi, i try to parse an xml document. but the function characterData which should process the found data is never called. startElement and endElement are called. it does not fails opening it and it gets te correct number of stories.u can have a look on the output at http://www.programmers-world.net/test/slashdot.php. thanks for any help bye sascha -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] XML parsing without the PHP4 XML functions
Wddx may also be an option. That would allow you to serialize the xml into php variables so that you could use them in your example. But if your provider won't compile xml in, I doubt you'll be able to get wddx. Shaun On Wed, 14 Feb 2001, Stefen Lars wrote: > Hello all > > I have recently been assigned the task of parsing an xml file and format the > contents of the file in HTML. The xml file lies on another server. Our web > space provider does not provide the XML functions (nor is he willing to > install them) :-gr. > > I am sure that I am not the only who has come across this problem. > > Would someone have already created a few functions to parse xml that they > are willing to share? > > I have the following structure to deal with: > > > > ProductName > Why does it not work > Because it is not turned on > > > > There are whole load of s in the file. > > I then want to display the contents a bit like this: > > echo $product; > echo $question; > > etc (of course with some HTML formatting, like a bulleted list). > > Any help would be really VERY appreciated! > > Thanks > > S > > > > _ > Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. > > > -- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] XML parsing without the PHP4 XML functions
I haven't done this in PHP as PHP comes w/ XML support but times past when I needed a fast way to parse something like that and knew the format would be simple I'd usually do something like make a function that knows all the possible splits w/in a layer (ie items are w/in the faq layer if they can occur inside faq tags) and then just recursively explode the string parts based on all know tags for that layer and build a nested array or prehaps nested objects. That is probably the simplist way if you don't want to mess w/ real parsing. If you have Unix access you might see if you can use Perl or a helper app to parse it into an easier to work w/ format. Stefen Lars wrote: > Hello all > > I have recently been assigned the task of parsing an xml file and > format the contents of the file in HTML. The xml file lies on another > server. Our web space provider does not provide the XML functions (nor > is he willing to install them) :-gr. > > I am sure that I am not the only who has come across this problem. > > Would someone have already created a few functions to parse xml that > they are willing to share? > > I have the following structure to deal with: > > > >ProductName >Why does it not work >Because it is not turned on > > > > There are whole load of s in the file. > > I then want to display the contents a bit like this: > > echo $product; > echo $question; > > etc (of course with some HTML formatting, like a bulleted list). > > Any help would be really VERY appreciated! > > Thanks > > S > > > > _ > Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] XML parsing without the PHP4 XML functions
If your satisfied with IE5.0 customers you could do all that without php, use an XSL file. Now if you want PHP to parse the XML file, I can see why, your going to have to get XML installed. Have you considered other providors? there are lots. Im one of them. Ive been told there are ways of adding modules dynamically on runtime http://php.net/manual/en/function.dl.php Ive never needed it / used it. sorry :( -- Chris Lee Mediawaveonline.com em. [EMAIL PROTECTED] ph. 250.377.1095 ph. 250.376.2690 fx. 250.554.1120 ""Stefen Lars"" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Hello all > > I have recently been assigned the task of parsing an xml file and format the > contents of the file in HTML. The xml file lies on another server. Our web > space provider does not provide the XML functions (nor is he willing to > install them) :-gr. > > I am sure that I am not the only who has come across this problem. > > Would someone have already created a few functions to parse xml that they > are willing to share? > > I have the following structure to deal with: > > > > ProductName > Why does it not work > Because it is not turned on > > > > There are whole load of s in the file. > > I then want to display the contents a bit like this: > > echo $product; > echo $question; > > etc (of course with some HTML formatting, like a bulleted list). > > Any help would be really VERY appreciated! > > Thanks > > S > > > > _ > Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] XML parsing without the PHP4 XML functions
Hello all I have recently been assigned the task of parsing an xml file and format the contents of the file in HTML. The xml file lies on another server. Our web space provider does not provide the XML functions (nor is he willing to install them) :-gr. I am sure that I am not the only who has come across this problem. Would someone have already created a few functions to parse xml that they are willing to share? I have the following structure to deal with: ProductName Why does it not work Because it is not turned on There are whole load of s in the file. I then want to display the contents a bit like this: echo $product; echo $question; etc (of course with some HTML formatting, like a bulleted list). Any help would be really VERY appreciated! Thanks S _ Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] XML parsing problems..
I didn't see any responses to this the other day when I asked so this time I'll include source.. just cutting and pasting so hopefully nothing gets clobbered.. When I parse this lil bit of raw data it parses properly. You can trace it and see that it opens and closes the tags properly and that it writes the $this->dom variable properly in the parsers close_tag () function. However when you return the $this->dom value afterwards the variables previous value is returned rather than the current value. Any ideas what I am doing wrong? Thanks. Howdy!"; $raw .= "My dog is cute. My cat is cute."; $xml_parser = new xml_parser; $document = $xml_parser->parse ( $raw ); print ""; print_r ( $document ); print ""; ?> encoding = $encoding; if ( $this->parser = xml_parser_create () ) { xml_set_object ( $this->parser, $this ); xml_set_element_handler ( $this->parser, "tag_open", "tag_close" ); xml_set_character_data_handler ( $this->parser, "cdata"); } } function parse ( $data ) { xml_parse ( $this->parser, $data ); } function tag_open ( $parser, $tag, $attributes ) { foreach ( $attributes as $key => $value ) { $attrib_str .= ", $key=$value"; } print "\n"; print "Open: $tag$attrib_str\n"; } function cdata ( $parser, $cdata ) { print "Data: $cdata\n"; } function tag_close ( $parser, $tag ) { print "Close: $tag\n"; print "\n"; } } class xml_parser { var $encoding; var $parser; var $opened_tags = array (); var $dom; function xml_parser ( $encoding = 'ISO-8859-1' ) { $this->encoding = $encoding; $this->create (); $this->configure (); } function create () { $this->parser = xml_parser_create ( $this->encoding ); } function configure () { xml_set_object ( $this->parser, $this ); xml_set_element_handler ( $this->parser, "open_tag", "close_tag" ); xml_set_character_data_handler ( $this->parser, "cdata" ); } function parse ( $data ) { xml_parse ( $this->parser, $data ); return $this->dom; } function open_tag ( $parser, $tag_type, $attributes ) { $tag = new xml_tag ( $tag_type, $attributes ); $this->opened_tags[] = $tag; } function close_tag ( $parser, $tag_type ) { $tag = array_pop ( $this->opened_tags ); $mother_tag = array_pop ( $this->opened_tags ); if ( $mother_tag ) { $mother_tag->add_tag ( $tag ); $this->opened_tags[] = $mother_tag; } elseif ( $tag ) { $this->dom = $tag; function cdata ( $parser, $cdata ) { $this->open_tag ( $parser, 'cdata', $cdata ); $this->close_tag ( $parser, 'cdata' ); } } class xml_tag { var $tag; var $arguments; var $contents = array (); function xml_tag ( $tag, $arguments = array() ) { // Name of the tag. $this->tag = $tag; // Array of argument/value pairs. $this->arguments = $arguments; } function add_tag ( $tag ) { $this->contents[] = $tag; } } ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] XML Parsing through Proxy
Hi Anybody got an idea? I am sitting behind a proxy and I want to able to parse an XML. So I have to use fsockopen() to get through my firewall and get the page. So far, everything goes wel, but I am not able to parse the file, because I think it is not in XML format if I use "GET http:// " Does anyone has an idea how I can solve this? My code so far (bits and pieces of anywhere :) ) Steve "HEADER_TAG", "ISSUE-NAME" => "STOCK_NAME", "LAST-SALE-PRICE" => "LAST_SALE", "PREVIOUS-CLOSE-PRICE" => "PREVIOUS_SALE", "NET-CHANGE-PRICE" => "CHANGE", "NET-CHANGE-PCT" => "CHANGE_PCT", "TODAYS-HIGH-PRICE" => "TODAYS_HIGH", "TODAYS-LOW-PRICE" => "TODAYS_LOW", ); # XML File to Parse $xmlFile_Location="http://quotes.nasdaq.com/quote.dll?page=xml&mode=stock&sy mbol=NETA"; // Functions # StartElement Of Parser function startElement($parser, $name, $attrs=''){ global $map_array, $temp, $current_tag; $current_tag = $name; if ($format = $map_array[$name]){ switch($name){ case 'NASDAQAMEX-DOT-COM': //echo $HTTP_GET_VARS['ticker']; break; default: break; } } } # EndElement Of Parser function endElement($parser, $name, $attrs=''){ global $map_array, $temp, $current_tag; if ($format = $map_array[$name]){ switch($name){ case 'NASDAQAMEX-DOT-COM': return_page($temp); $temp = ''; break; default: break; } } } # Process the Data between XML-Tags function characterData($parser, $data){ global $current_tag, $temp, $catID; switch($current_tag){ case 'ISSUE-NAME': $temp['STOCK_NAME'] = $data; $current_tag = ''; break; case 'LAST-SALE-PRICE': $temp['LAST_SALE'] = $data; $current_tag = ''; break; default: break; } } # Create the XML Parser and set options $type="UTF-8"; $xml_parser = xml_parser_create($type); xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, true); xml_set_element_handler($xml_parser, 'startElement','endElement'); xml_set_character_data_handler($xml_parser, 'characterData'); /* Open a connection through Proxy with Nasdaq and start parsing */ $sockPointer = fsockopen($proxy_ip,$proxy_port, $errNo, $errStr,30); //Connect to Proxy if( !$sockPointer ){ echo "$errStr Proxy not Available \n\n"; exit(); } else{ fputs($sockPointer,"GET $xmlFile_Location/ \n\n"); while (!feof($sockPointer)){ $Data = fgets($sockPointer, 10); $tag= "\n\n"; if( eregi("xml version",$Data) ){ $Parse=1; } if($Parse==1){ if (!($Data = utf8_encode($Data))){ echo 'ERROR'."\n"; } if (!xml_parse($xml_parser, $Data, feof($sockPointer))){ die(sprintf( "XML error: %s at line %d\n\n", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser))); } } } fclose($sockPointer); } xml_parser_free($xml_parser); ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
FW: [PHP] XML Parsing The Sequel II
-Original Message- From: Steve Haemelinck [mailto:[EMAIL PROTECTED]] Sent: maandag 12 februari 2001 21:52 To: 'Steve Haemelinck' Subject: RE: [PHP] XML Parsing The Sequel II Ok, I solved the problems with my proxy, I can get the xml but I can not get it completely. Why? Because I am not able to open the tags and that is why it stops at the first one. Does anyone has an idea how I can open the tags ? This is my code so far :) function GetXMLData($xmlFile_Location){ # Proxy Settings $proxy_ip="proxy.server.be"; $proxy_port80; /* Get the required data from Nasdaq */ $sockPointer = fsockopen($proxy_ip,$proxy_port, $errNo, $errStr,30); //Connect to Proxy if( !$sockPointer ){ echo "$errStr Proxy not Available \n \n"; exit(); } else{ fputs($sockPointer,"GET $xmlFile_Location / HTTP/1.0\n\n"); while (!feof($sockPointer)){ $Data .= fgets($sockPointer, 1000); } } /* Store the locally for Parsing */ SaveDataLocally($Data, ".xml"); } -Original Message- From: Steve Haemelinck [mailto:[EMAIL PROTECTED]] Sent: maandag 12 februari 2001 20:42 To: 'Steve Haemelinck' Cc: PHP Mailing Listl (E-mail) Subject:RE: [PHP] XML Parsing The Sequel II I think I found the problem. Because I am behind a proxy I can not connect to http://quotes.nasdaq.com. And get the data !!! -Original Message- From: Steve Haemelinck [mailto:[EMAIL PROTECTED]] Sent: zondag 11 februari 2001 11:13 To: PHP Mailing Listl (E-mail) Subject:[PHP] XML Parsing The Sequel II Ok, yesterday I had problems parsing an XML from Nasdaq. Thx to Matt these problems have been solved and I am know able to parse any XML without problems (I hope). But I have one question: In order to parse an XML you have to tell your parser where to find the document: $xml_file = "test.xml'; This works perfectly, but If you want to get the XML files from Nasdaq you have to say $xml_file = http://quotes.nasdaq.com/quote.dll?page=xml&mode=stock&symbol=NETA; This however doe not work !!! Why? How can I overcome this problem? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] XML Parsing The Sequel II
I think I found the problem. Because I am behind a proxy I can not connect to http://quotes.nasdaq.com. And get the data !!! -Original Message- From: Steve Haemelinck [mailto:[EMAIL PROTECTED]] Sent: zondag 11 februari 2001 11:13 To: PHP Mailing Listl (E-mail) Subject:[PHP] XML Parsing The Sequel II Ok, yesterday I had problems parsing an XML from Nasdaq. Thx to Matt these problems have been solved and I am know able to parse any XML without problems (I hope). But I have one question: In order to parse an XML you have to tell your parser where to find the document: $xml_file = ''test.xml'; This works perfectly, but If you want to get the XML files from Nasdaq you have to say $xml_file = http://quotes.nasdaq.com/quote.dll?page=xml&mode=stock&symbol=NETA; This however doe not work !!! Why? How can I overcome this problem? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] XML Parsing The Sequel II
-Original Message- From: Steve Haemelinck [mailto:[EMAIL PROTECTED]] Sent: zondag 11 februari 2001 11:13 To: PHP Mailing Listl (E-mail) Subject:[PHP] XML Parsing The Sequel II Ok, yesterday I had problems parsing an XML from Nasdaq. Thx to Matt these problems have been solved and I am know able to parse any XML without problems (I hope). But I have one question: In order to parse an XML you have to tell your parser where to find the document: $xml_file = ''test.xml'; This works perfectly, but If you want to get the XML files from Nasdaq you have to say $xml_file = http://quotes.nasdaq.com/quote.dll?page=xml&mode=stock&symbol=NETA; This however doe not work !!! Why? How can I overcome this problem? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] XML Parsing The Sequel II
here is come code (not exactly what you need) that sends an XML file(variable) to an XML server, and then gets the XML response from the server and writes it out to a file, returning the filename as the function return for the php file to resume its processing of the file in the XML parser (yet another function) Tried to cut out totally irrelavent or site specific stuff, and added a few quick comments. Hopefuly you can follow the logic. Dave in main PHP file in ./shipping/shipping.php \n"; } else { $xmlTransmit="\n # assembing and formatting the XML document for transmission \n"; fputs ($sockPointer, $xmlTransmit); # # get the response from the server # while (!feof($sockPointer)) { $socketResponse=fgets($sockPointer,4096); $xmlResponse="$xmlResponse".$socketResponse; } fclose($sockPointer); } # # here is the stuff you were really interested in # # get a timestamp to save the temp file as $xmlFile=time(); # create the temp file $xmlFile="./shipping/".$xmlFile.".xml"; $xfp=fopen($xmlFile,"w"); # write the temp file from the response variable fwrite($xfp,$xmlResponse); fclose($xfp); # return the temp filename for the parser to process return $xmlFile; } in ./shipping/shipping2.php HTML file out of the function return $returnShipTable; } ?> -Original Message- From: Steve Haemelinck [mailto:[EMAIL PROTECTED]] Sent: Sunday, February 11, 2001 9:12 AM To: 'Dave' Cc: PHP Mailing Listl (E-mail) Subject: RE: [PHP] XML Parsing The Sequel II But how can I automate the saving locally of the file !!! -Original Message- From: Dave [mailto:[EMAIL PROTECTED]] Sent: zondag 11 februari 2001 14:44 To: PHP Mailing Listl (E-mail) Subject:RE: [PHP] XML Parsing The Sequel II here is some logic, I'm sure you can flesh out the code. fopen -r the URL read the results into a variable, fopen -w to write a local temp file (if the parser you build actially requires a "file") save it locally and pass the filename variable to your XML parser function if your parser can work from a variable, then just pass the read variable to your parser. Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] XML Parsing The Sequel II
But how can I automate the saving locally of the file !!! -Original Message- From: Dave [mailto:[EMAIL PROTECTED]] Sent: zondag 11 februari 2001 14:44 To: PHP Mailing Listl (E-mail) Subject:RE: [PHP] XML Parsing The Sequel II here is some logic, I'm sure you can flesh out the code. fopen -r the URL read the results into a variable, fopen -w to write a local temp file (if the parser you build actially requires a "file") save it locally and pass the filename variable to your XML parser function if your parser can work from a variable, then just pass the read variable to your parser. Dave -Original Message- From: Steve Haemelinck [mailto:[EMAIL PROTECTED]] Sent: Sunday, February 11, 2001 5:13 AM To: PHP Mailing Listl (E-mail) Subject: [PHP] XML Parsing The Sequel II Ok, yesterday I had problems parsing an XML from Nasdaq. Thx to Matt these problems have been solved and I am know able to parse any XML without problems (I hope). But I have one question: In order to parse an XML you have to tell your parser where to find the document: $xml_file = ''test.xml'; This works perfectly, but If you want to get the XML files from Nasdaq you have to say $xml_file = http://quotes.nasdaq.com/quote.dll?page=xml&mode=stock&symbol=NETA; This however doe not work !!! Why? How can I overcome this problem? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] XML Parsing The Sequel II
here is some logic, I'm sure you can flesh out the code. fopen -r the URL read the results into a variable, fopen -w to write a local temp file (if the parser you build actially requires a "file") save it locally and pass the filename variable to your XML parser function if your parser can work from a variable, then just pass the read variable to your parser. Dave -Original Message- From: Steve Haemelinck [mailto:[EMAIL PROTECTED]] Sent: Sunday, February 11, 2001 5:13 AM To: PHP Mailing Listl (E-mail) Subject: [PHP] XML Parsing The Sequel II Ok, yesterday I had problems parsing an XML from Nasdaq. Thx to Matt these problems have been solved and I am know able to parse any XML without problems (I hope). But I have one question: In order to parse an XML you have to tell your parser where to find the document: $xml_file = ''test.xml'; This works perfectly, but If you want to get the XML files from Nasdaq you have to say $xml_file = http://quotes.nasdaq.com/quote.dll?page=xml&mode=stock&symbol=NETA; This however doe not work !!! Why? How can I overcome this problem? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] XML Parsing The Sequel II
Ok, yesterday I had problems parsing an XML from Nasdaq. Thx to Matt these problems have been solved and I am know able to parse any XML without problems (I hope). But I have one question: In order to parse an XML you have to tell your parser where to find the document: $xml_file = ''test.xml'; This works perfectly, but If you want to get the XML files from Nasdaq you have to say $xml_file = http://quotes.nasdaq.com/quote.dll?page=xml&mode=stock&symbol=NETA; This however doe not work !!! Why? How can I overcome this problem? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] XML Parsing with PHP
You know, some of these guys are members of this list. I don't think they make any claims about being the definitive end all be all source for all things PHP but rather are a bunch of folks sharing their PHP experiences/knowledge. I'd say that's pretty generous of them. -Brian > -Original Message- > From: Chris Lee [mailto:[EMAIL PROTECTED]] > Sent: Monday, February 05, 2001 1:19 PM > To: [EMAIL PROTECTED] > Subject: Re: [PHP] XML Parsing with PHP > > > PHPbulder.com classically has terrible tutorials. I myself am trying to > learn this XML deal. PHPbuilders code, cut and paste is filled with parse > errors. after fiddling Ive got his example to work, but I havent > a clue how? > he posts this stupid two page article, page one is nothing, page two is > nothin plus broken code. He doesn explain what even one of his four > functions are for. completely confused. I hate to ramble, but > phpbuilder is > a terrible site that ruins php for many newbies. > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] XML Parsing with PHP
If you're talking about my article on PHPBuilder Found at: http://www.phpbuilder.com/columns/joe2907.php3 You can feel free to ask me any questions you like in private (I write them because I like supporting a community that has helped me so much) --Joe On Mon, Feb 05, 2001 at 10:19:17AM -0800, Chris Lee wrote: > PHPbulder.com classically has terrible tutorials. I myself am trying to > learn this XML deal. PHPbuilders code, cut and paste is filled with parse > errors. after fiddling Ive got his example to work, but I havent a clue how? > he posts this stupid two page article, page one is nothing, page two is > nothin plus broken code. He doesn explain what even one of his four > functions are for. completely confused. I hate to ramble, but phpbuilder is > a terrible site that ruins php for many newbies. > > > -- > > > > Chris Lee > Mediawaveonline.com > [EMAIL PROTECTED] > > > > "Joe Stump" <[EMAIL PROTECTED]> wrote in message > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > phpbuilder.com - there are a few articles on the site about XML > > > > --Joe > > > > On Sun, Feb 04, 2001 at 05:02:43PM +0100, Steve Haemelinck wrote: > > > Where can I find some info on parsing XML with PHP? > > > I am not looking for functions, but examples and explanations ! > > > > > > Thx > > > > > > > > > -- > > > PHP General Mailing List (http://www.php.net/) > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > > > -- > > > > -- > - > > Joe Stump, PHP Hacker, > -o) > > http://www.miester.org http://www.care2.com > /\\ > > "It's not enough to succeed. Everyone else must fail" -- Larry Ellison > _\_V > > -- > - > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] -- --- Joe Stump, PHP Hacker, [EMAIL PROTECTED] -o) http://www.miester.org http://www.care2.com /\\ "It's not enough to succeed. Everyone else must fail" -- Larry Ellison _\_V --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] XML Parsing with PHP
PHPbulder.com classically has terrible tutorials. I myself am trying to learn this XML deal. PHPbuilders code, cut and paste is filled with parse errors. after fiddling Ive got his example to work, but I havent a clue how? he posts this stupid two page article, page one is nothing, page two is nothin plus broken code. He doesn explain what even one of his four functions are for. completely confused. I hate to ramble, but phpbuilder is a terrible site that ruins php for many newbies. -- Chris Lee Mediawaveonline.com [EMAIL PROTECTED] "Joe Stump" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > phpbuilder.com - there are a few articles on the site about XML > > --Joe > > On Sun, Feb 04, 2001 at 05:02:43PM +0100, Steve Haemelinck wrote: > > Where can I find some info on parsing XML with PHP? > > I am not looking for functions, but examples and explanations ! > > > > Thx > > > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > To contact the list administrators, e-mail: [EMAIL PROTECTED] > > -- > > -- - > Joe Stump, PHP Hacker, -o) > http://www.miester.org http://www.care2.com /\\ > "It's not enough to succeed. Everyone else must fail" -- Larry Ellison _\_V > -- - > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] XML Parsing with PHP
phpbuilder.com - there are a few articles on the site about XML --Joe On Sun, Feb 04, 2001 at 05:02:43PM +0100, Steve Haemelinck wrote: > Where can I find some info on parsing XML with PHP? > I am not looking for functions, but examples and explanations ! > > Thx > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > To contact the list administrators, e-mail: [EMAIL PROTECTED] -- --- Joe Stump, PHP Hacker, [EMAIL PROTECTED] -o) http://www.miester.org http://www.care2.com /\\ "It's not enough to succeed. Everyone else must fail" -- Larry Ellison _\_V --- -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] XML Parsing with PHP
Where can I find some info on parsing XML with PHP? I am not looking for functions, but examples and explanations ! Thx -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]