By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,949 Members | 1,869 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,949 IT Pros & Developers. It's quick & easy.

xml_set_character_data_handler

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.