473,386 Members | 1,804 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

xml_set_character_data_handler

Hi Folks:

I hope this is an OK place to post a newbie question. I'm trying to
parse an XML file that contains a URL as one of it's nodes. For
instance:

http://wsdsapi-p.xxxxxx.com/clickserver/_iceUrlFlag=1?rawURL=http%3A%2F%2Fwww.google.com%2 Faclk%3Fsa%3DL%26ai%3DB7aKJlO76SIPGEpiUtQOAg5iLAq2 ot1Pd9Mn6CdaXmQXwo1cQARgBIKj29AEoAzgBUMaXqLD6_____ wFgyQbIAQGAAgHIAqGYuAHZA2TCF_9mH1G-%26num%3D1%26sig%3DAGiWqtzE4dJ8v6950akv_hV5zHIHySG rjg%26q%3Dhttp%3A%2F%2Fwww.rkdms.com%2Fredirect%25 3Fc%253D50920722%2526en%253D1%2526cl%253D180%2526u %253Dhttp%25253A%25252F%25252Fwww.1800flowers.com% 25252Frefer.do%25253Fr%25253Dgoogenrkg%252526u%252 53Ddataset.do%2525253Fdataset%2525253D10535&amp;0= &amp;1=0&amp;4=206.29.197.150&amp;5=10.10.10.10&am p;9=a2bdef1e64514dae8c1f744db831c901&amp;10=1&amp; 11=pemonitor.api&amp;13=search&amp;14=245874&amp;1 5=main-title&amp;17=1&amp;18=1&amp;19=1&amp;20=1&amp;21=0 &amp;22=5qzGM15%2Fwmc%3D&amp;40=oKLlDmjyxsJIBQ4SuI 5EWw%3D%3D&amp;_IceUrl=true</site-link>

.............

Here's the problem...I registered my callback function "contents" in:

xml_set_character_data_handler($xml_parser, "contents");

....but whenever it processes the URL above, it only captures half of
it...basically everything before the first ampersand.

By the way, I'm reading 8K at a time. See here:

$fp = fopen($file, "r");
$data = fread($fp, 80000);
.................

So my question is why isn't the callback function parsing the entire
URL? Is there something setting it off? How can I force the XML
parser to read all of it?

Thanks

Oct 20 '08 #1
1 4838
On Mon, 20 Oct 2008 18:32:22 +0200, Techlinks <le*****@techlinks.com
wrote:
Hi Folks:

I hope this is an OK place to post a newbie question. I'm trying to
parse an XML file that contains a URL as one of it's nodes. For
instance:

http://wsdsapi-p.xxxxxx.com/clickserver/_iceUrlFlag=1?rawURL=http%3A%2F%2Fwww.google.com%2 Faclk%3Fsa%3DL%26ai%3DB7aKJlO76SIPGEpiUtQOAg5iLAq2 ot1Pd9Mn6CdaXmQXwo1cQARgBIKj29AEoAzgBUMaXqLD6_____ wFgyQbIAQGAAgHIAqGYuAHZA2TCF_9mH1G-%26num%3D1%26sig%3DAGiWqtzE4dJ8v6950akv_hV5zHIHySG rjg%26q%3Dhttp%3A%2F%2Fwww.rkdms.com%2Fredirect%25 3Fc%253D50920722%2526en%253D1%2526cl%253D180%2526u %253Dhttp%25253A%25252F%25252Fwww.1800flowers.com% 25252Frefer.do%25253Fr%25253Dgoogenrkg%252526u%252 53Ddataset.do%2525253Fdataset%2525253D10535&amp;0= &amp;1=0&amp;4=206.29.197.150&amp;5=10.10.10.10&am p;9=a2bdef1e64514dae8c1f744db831c901&amp;10=1&amp; 11=pemonitor.api&amp;13=search&amp;14=245874&amp;1 5=main-title&amp;17=1&amp;18=1&amp;19=1&amp;20=1&amp;21=0 &amp;22=5qzGM15%2Fwmc%3D&amp;40=oKLlDmjyxsJIBQ4SuI 5EWw%3D%3D&amp;_IceUrl=true</site-link>

............

Here's the problem...I registered my callback function "contents" in:

xml_set_character_data_handler($xml_parser, "contents");

...but whenever it processes the URL above, it only captures half of
it...basically everything before the first ampersand.
Go to http://nl2.php.net/xml_set_character_data_handler, and read the
(currently latest comment) of jhill at live dot com, 29-Aug-2008 04:11

When possible, I much prefer to use DOM if possible though.
--
Rik Wasmus
Oct 21 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: dmassie | last post by:
is there anyway to increase the maximum size of the data part of: xml_set_character_data_handler(parser,data) since I've been told that it is set to 1024. Thanks Daniel
4
by: Andrew Banks | last post by:
I've been struggling with this for the past 2 days and have tried various solutions. I need to parse the following XML file and extract the data into variables <?xml version="1.0"...
7
by: J Sharman | last post by:
I am fairly familiar with PHP and MYSQL and I know a little about XML. I would like to know if it is possible to do queries on XML similar to the way that you do queries on MYSQL and then use the...
2
by: michael nieuwenhuizen | last post by:
<newbie alert> i have 2 related arrays that i wanna sort at once. if i try: print_r($my_array1); array_multisort($my_array1, SORT_ASC, $my_array2, SORT_ASC); print_r($my_array1); both...
3
by: wenke | last post by:
Hi, I am using the following code (see below) from php.net (http://www.php.net/manual/en/ref.xml.php, example 1) to parse an XML file (encoded in UTF-8). I changed the code slightly so that the...
6
by: Martman | last post by:
I am new to PHP but testing the ability to read an RSS xml feed. I have successfully retrieved, read, and displayed an RSS feed from pcworld. However, when you click on one of the links it adds...
5
by: Mayhem | last post by:
I would like to integrate an RSS newsfeed into my website but can't seem to figure out how. Has anyone got any pointers for me? E.
2
by: Noyb | last post by:
I've set up a news links section using the RSS parsing tutorial found here: http://www.sitepoint.com/article/560 Everything works great but depending on the feed source there may be 3 news links...
4
by: Noyb | last post by:
Posted this a while ago, never got so much as a peep. Please take a look and give any thoughts. I've set up a news links section using the RSS parsing tutorial found here:...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.