xml_set_character_data_handler

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Techlinks

    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?r awURL=http%3A%2 F%2Fwww.google. com%2Faclk%3Fsa %3DL%26ai%3DB7a KJlO76SIPGEpiUt QOAg5iLAq2ot1Pd 9Mn6CdaXmQXwo1c QARgBIKj29AEoAz gBUMaXqLD6_____ wFgyQbIAQGAAgHI AqGYuAHZA2TCF_9 mH1G-%26num%3D1%26si g%3DAGiWqtzE4dJ 8v6950akv_hV5zH IHySGrjg%26q%3D http%3A%2F%2Fww w.rkdms.com%2Fr edirect%253Fc%2 53D50920722%252 6en%253D1%2526c l%253D180%2526u %253Dhttp%25253 A%25252F%25252F www.1800flowers .com%25252Frefe r.do%25253Fr%25 253Dgoogenrkg%2 52526u%25253Dda taset.do%252525 3Fdataset%25252 53D10535&amp;0= &amp;1=0&amp;4= 206.29.197.150& amp;5=10.10.10. 10&amp;9=a2bdef 1e64514dae8c1f7 44db831c901&amp ;10=1&amp;11=pe monitor.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=5q zGM15%2Fwmc%3D& amp;40=oKLlDmjy xsJIBQ4SuI5EWw% 3D%3D&amp;_IceU rl=true</site-link>

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

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

    xml_set_charact er_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

  • Rik Wasmus

    #2
    Re: xml_set_charact er_data_handler

    On Mon, 20 Oct 2008 18:32:22 +0200, Techlinks <lesterj@techli nks.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?r awURL=http%3A%2 F%2Fwww.google. com%2Faclk%3Fsa %3DL%26ai%3DB7a KJlO76SIPGEpiUt QOAg5iLAq2ot1Pd 9Mn6CdaXmQXwo1c QARgBIKj29AEoAz gBUMaXqLD6_____ wFgyQbIAQGAAgHI AqGYuAHZA2TCF_9 mH1G-%26num%3D1%26si g%3DAGiWqtzE4dJ 8v6950akv_hV5zH IHySGrjg%26q%3D http%3A%2F%2Fww w.rkdms.com%2Fr edirect%253Fc%2 53D50920722%252 6en%253D1%2526c l%253D180%2526u %253Dhttp%25253 A%25252F%25252F www.1800flowers .com%25252Frefe r.do%25253Fr%25 253Dgoogenrkg%2 52526u%25253Dda taset.do%252525 3Fdataset%25252 53D10535&amp;0= &amp;1=0&amp;4= 206.29.197.150& amp;5=10.10.10. 10&amp;9=a2bdef 1e64514dae8c1f7 44db831c901&amp ;10=1&amp;11=pe monitor.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=5q zGM15%2Fwmc%3D& amp;40=oKLlDmjy xsJIBQ4SuI5EWw% 3D%3D&amp;_IceU rl=true</site-link>
    >
    ............
    >
    Here's the problem...I registered my callback function "contents" in:
    >
    xml_set_charact er_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

    Comment

    Working...