simplexml

Parse KML file with PHP

人盡茶涼 提交于 2019-12-24 02:48:11
问题 Is there a way to parse google maps *.kml file with simple_xml_load_file("*.kml") ? I need to save in my database name and coordinates of each polygons registered in my KML file. On my PHP script, simple_xml_load_file("*.kml") return false, so I can't read it. <?xml version="1.0" encoding="UTF-8"?> <kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom"> <Document> <Schema> ...

simplexml_load_file error in PHP 5.3

笑着哭i 提交于 2019-12-24 02:45:15
问题 I'm using the following code to read an RSS feed and output the results. function home_page_parser($feedURL) { $rss = simplexml_load_file($feedURL); $i = 0; echo "<ul>"; foreach ($rss->channel->item as $feedItem) { $i++; $myDate = ($feedItem->pubDate); $dateForm = explode(" ", $myDate); echo "<li class=\"rss-feed\"><a href=\"$feedItem->link\" title=\"$feedItem->title\" target=\"_blank\">".$feedItem->title."</a><br />" .$feedItem->pubDate. "</li>"; if($i >= 3) break; echo "</ul>"; } } It is

SimpleXML PHP parse OCR XML document

两盒软妹~` 提交于 2019-12-24 02:22:52
问题 Let's say I have this XML document, (actually an XML file containing the result of an OCR document: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <document xmlns="http://www.abbyy.com/FineReader_xml/FineReader10-schema-v1.xml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.abbyy.com/FineReader_xml/FineReader10-schema-v1.xml http://www.abbyy.com/FineReader_xml/FineReader10-schema-v1.xml" version="1.0" producer="ABBYY FineReader Engine 11"

Write a foreach loop for array of SimpleXMLElements

别说谁变了你拦得住时间么 提交于 2019-12-24 02:11:44
问题 I am using the XPath in PHP 5 to parse a XML document. The problem I have is writing a foreach to correctly display the following array: XML document sample value 1 value 2 $xmlfile = 'link_to_file.xml'; $xmlRaw = file_get_contents($xmlfile); $xml = new SimpleXMLElement($xmlRaw); $install_files = $xml->xpath('//files'); foreach($install_files as $row) { echo $row['file']; } //var_dump for $row gives the following array(1) { [0]=> object(SimpleXMLElement)#21 (2) { ["file"]=> string(12) "value

How to access element like <game:title> with simplexml?

对着背影说爱祢 提交于 2019-12-24 01:43:01
问题 I'm trying to parse XML feed with SimpleXML, here is a chunk of the XML tree: <item> <game:name>Tetris</game:name> <game:desc>Way Cool Game</game:desc> <size>5mb</size> </item> Well actually, I can succesfully access 'size' with something like that: $item->size , but how do I get value? Of course I can't call like that: $item->game:name , and I don't know how what goes after ':' is called. Is it a parameter, attribute or what? Thanks for advance! 回答1: You need to define the namespace for game

PHP SimpleXML recursive function to list children and attributes

♀尐吖头ヾ 提交于 2019-12-24 01:24:13
问题 I need some help on the SimpleXML calls for a recursive function that lists the elements name and attributes. Making a XML config file system but each script will have it's own config file as well as a new naming convention. So what I need is an easy way to map out all the elements that have attributes, so like in example 1 I need a simple way to call all the processes but I don't know how to do this without hard coding the elements name is the function call. Is there a way to recursively

PHP SimpleXML Group By Element Type

荒凉一梦 提交于 2019-12-24 00:52:32
问题 Ok here's my dilemma. I am looking for a way to consolidate the data in a group using SimpleXML in PHP . Here's what I mean. Let's say I have an xml that looks like this: <favorites> <interesting> <type>Movie</type> <character>James Bond</character> <name>Casino Royale</name> </interesting> <interesting> <type>Movie</type> <character>Jason Bourne</character> <name>Bourne Identity</name> </interesting> <interesting> <type>Book</type> <character>Lindsay Ford</character> <name>Shantaram</name> <

How to ignore case when parsing with simplexml?

醉酒当歌 提交于 2019-12-24 00:44:51
问题 can I make simple XML ignore case of the node and attributes names? like <eleMent attriBute="aaa"> </ELEMENT> 回答1: can I make simple XML ignore case of the node and attributes names? No. 回答2: The only way I see is to change the case of the xml string you want to parse before the call of SimpleXMLElement . Something like this : $content = mb_strtolower(file_get_contents('myfile.xml'), 'UTF-8'); $simpleXmlElement = new SimpleXMLElement($content); Be aware that you will have performance issue

simplexml_load_file Document is empty

僤鯓⒐⒋嵵緔 提交于 2019-12-24 00:43:24
问题 I'm pulling from a RSS feed: http://search.library.utoronto.ca/UTL/index?Ntt=starcraft&Ntk=Anywhere&Ntx=mode+matchallpartial&N=0&Nu=p_work_normalized&Np=1&rss=1 If you navigate to that with a browser, you get a nice xml page. However, if I do simplexml_load_file("the above url"); in php, I get 1: parser error : Document is empty 1: parser error : Start tag expected, '<' not found in my_file So why can the browser get it but not PHP? If I do file_get_contents("the above url") the function

simplexml and accessing feedburner's : [duplicate]

耗尽温柔 提交于 2019-12-24 00:42:56
问题 This question already has an answer here : Reference - how do I handle namespaces (tags and attributes with colon in) in SimpleXML? (1 answer) Closed last year . I'm trying trying to use simplexml to read a feedburner xml. I can read every properties in the xml but not the keys with ':' in it. Example "feedburner:origLink". When I vardump the items, those keys with : doesn't show up. And I can't do like $s->item->feedburner:origLink. 回答1: You're dealing with namespaces, and this Sitepoint