Jump to content

PHP XML Paser


Renidrag

Recommended Posts

I am using the XML_Paser to parse Yahoo Search XML and it has been years since I worked with XML and these classes and functions in PHP are new to me, I can easily go throught and display the search listings that are contained in the attributes - BUT - I can not display the value of the text within the ClickURL element, I can only seen to get display element attributes with my function start($parser,$element,$attr)

 

I was looking into using Simple XML but the hosting service only uses php 4.3.9 and Simple XML requires PHP 5

 

Can someone show me how to display the text within the element, not the attributes, thanks

 

Link to comment
Share on other sites

Update,

 

I found the solution, when using xml_parser() you set the xml_set_element_handler($this->parser,"start","stop"); which iterates through the xml feed, during this iteration the xml_set_character_data_handler($this->parser,"char"); is called and you use the function set above "char" to handle the data within the xml elements where as the "start" and "stop" functions handle the element attributes.

 

So basically the xml_parser is setup to do these steps, you have to set the name you want on the functions and you get to tell the functions what they will do - Documentation could be better thou and some examples of the flow of iteration etc.

 

but all in all my faith is restored

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.