javascript - Extract complex URL from XML with JS or PHP -
i extracting data database using api; api returns data xml file.
i able put api return xml file on server, using php (file_get_contents() , file_put_contents()). fields, able parse xml file created , manipulate using either php or javascript (i.e., i've done both successfully).
one of field values need call complex url automatically downloads image file. able call field api, , goes xml file rest of fields.
however, both php parser ( simplexml_load_file() ) or javascript parser ( xmlhttprequest() ) fail read xml file complex url field. know have write code parsing because said, can manipulate other field these parsers.
how can @ agencyphoto field?
<?xml version="1.0" encoding="utf-8" standalone="no"?> <results count="4"> <row id="14" created="2013-04-07 21:43:59" updated="2013-05-05 19:12:21"> <agencyphoto>https://fw.civicore.com/vtmentoring/index.php?downloadfile=1&table=agencies&field=agencyphoto&check=969ac322f0347d4358bd3a7852b7b282&key=14</agencyphoto> </row> </results>
your xml doesn't valid. url contains unescaped &
characters illegal. should escaped &
or put cdata. first fix before continuing.
so either
<agencyphoto>https://fw.civicore.com/vtmentoring/index.php?downloadfile=1&table=agencies&field=agencyphoto&check=969ac322f0347d4358bd3a7852b7b282&key=14</agencyphoto>
or
<agencyphoto><![cdata[https://fw.civicore.com/vtmentoring/index.php?downloadfile=1&table=agencies&field=agencyphoto&check=969ac322f0347d4358bd3a7852b7b282&key=14]]></agencyphoto>
Comments
Post a Comment