simplexml

alternatives to simpleXML for parsing xml files with PHP

不羁的心 提交于 2019-12-07 06:47:47
问题 i just want to know if there are any alternatives to simpleXML for parsing XML Data with PHP. For example if simpleXML module is not loaded or even if there is a lib/class out there that has a better performance then SimpleXML. 回答1: Obviously there's a ton of different way to process XML both as PHP extensions and userspace librairies. The problem is they are all much much more complicated than SimpleXML and nowhere as fast for random access. I'm not sure what's the goal of your question

How to check if element exists with SimpleXML? [duplicate]

巧了我就是萌 提交于 2019-12-07 03:43:39
问题 This question already has answers here : php SimpleXML check if a child exists (15 answers) Closed 5 years ago . I have the following (simplified XML): <?xml version="1.0" encoding="UTF-8" ?> <products> <product> <artnr>xxx1</artnr> </product> </products> And the following (again simplified PHP code): $xml= @simplexml_load_file($filename); foreach ($xml->product as $product) { if (!$this->validate_xml_product($product)) { continue; } } function validate_xml_product($product) { if (!property

Parsing google calendar XML feed

左心房为你撑大大i 提交于 2019-12-07 02:44:25
问题 I've got XML feed from public google calendar. Looks like this: <?xml version='1.0' encoding='UTF-8'?> <feed xmlns='................' xmlns:gd='http://schemas.google.com/g/2005'> <id>http://www.google.com/calendar/feeds/........./public/full</id> <updated>2009-08-24T10:57:00.000Z</updated> <category scheme='http://schemas.google.com/g/2005#kind' term='http://schemas.google.com/g/2005#event'/> <title type='text'>Sports Events</title> ..... <entry> <id>...........</id> <published>2009-08-14T00

Checking if an object attribute is set - SimpleXML

可紊 提交于 2019-12-07 01:43:49
问题 I have some XML I am using PHP's SimpleXML class with and I have elements within the XML such as: <condition id="1" name="New"></condition> <condition id="2" name="Used"></condition> However they are not always there, so I need to check if they exist first. I have tried.. if (is_object($bookInfo->page->offers->condition['used'])) { echo 'yes'; } as well as.. if (isset($bookInfo->page->offers->condition['used'])) { echo 'yes'; } But neither work. They only work if I remove the attribute part.

php xpath problems

≡放荡痞女 提交于 2019-12-07 01:00:25
问题 I am trying to parse a blogspot feed using xpath but it doesnt seem to be working with anything that I try. I am not sure if it is because of the namespaces or what but I was hoping someone could help me. Here is the code: $xml = simplexml_load_file('http://feeds.feedburner.com/blogspot/MKuf'); $next = $xml->xpath("//link[@rel='next']"); print_r($next); This is just returning an empty array and it should not be. I tried it doing just link or just entry and it still is returning empty. The

PHP SimpleXML new line

左心房为你撑大大i 提交于 2019-12-07 00:21:43
问题 I have created a XML file using PHP's simple XML, saved the file. When opening the file in php using fopen and printing the contents. my XML looks like this: (see below) <?xml version="1.0" encoding="UTF-8"?> <home><orderList><delivery_cost>0.00</delivery_cost><delivery_surname>TEST</delivery_surname><delivery_postcode>1234</delivery_postcode><status>1</status></orderList></home> I want the xml file looking all indented and on new lines for each element. Does anybody know how to do this?

RSS XML Parsing issue (How to get media content value from the RSS feed?) [duplicate]

不想你离开。 提交于 2019-12-06 22:32:53
This question already has answers here : Using SimpleXML to read RSS feed (2 answers) Closed 6 years ago . I have a rss feed url which generates an xml as follows: <?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:media="http://search.yahoo.com/mrss/" xmlns:flow="http://www.flownetworks.com/schemas/media/0.1.0"><channel> <title>flow-Media Catalog</title> <link>http://catalog.flownetworks.com/catalogs/1/videos.mrss</link> <description>Video Catalog</description> <image> <url>http://images.flow-media.com/flow_media_current.png</url> <title>Get to know flow-Media</title> <link>http:/

SimpleXML & PHP: Extract part of XML document & convert as Array

落爺英雄遲暮 提交于 2019-12-06 21:47:28
Consider the following XML: <?xml version="1.0" encoding="UTF-8"?> <OS> <data> <OSes> <centos> <v_5> <i386> <id>centos5-32</id> <name>CentOS 5 - 32 bit</name> <version>5</version> <architecture>32</architecture> <os>centos</os> </i386> <x86_64> <id>centos5-64</id> <name>CentOS 5 - 64 bit</name> <version>5</version> <architecture>64</architecture> <os>centos</os> </x86_64> </v_5> <v_6> <i386> <id>centos6-32</id> <name>CentOS 6 - 32 bit</name> <version>6</version> <architecture>32</architecture> <os>centos</os> </i386> <x86_64> <id>centos6-64</id> <name>CentOS 6 - 64 bit</name> <version>6<

PHP Simplexml_Load_File fails

*爱你&永不变心* 提交于 2019-12-06 16:44:27
I have successfully been able to get a pubmed results page in xml format and write the contents to a local file "Publications.xml". The problem is when I use simplexml_load_file("Publications.xml"), it fails. Not able to figure out why. <?php $feed = 'http://www.ncbi.nlm.nih.gov/pubmed?term=carl&sort=pubdate&report=xml'; $local = 'Publications.xml'; $curtime = time(); $filemodtime; if( (!file_exists($local)) || (time() - filemtime($local)) > 86400 ) { $contents = file_get_contents($feed); $fp = fopen($local,"w"); fwrite($fp, $contents); fclose($fp); } $xml = simplexml_load_file($local) or (

PHP Parse Soap Response Issue - SimpleXMLElement

大兔子大兔子 提交于 2019-12-06 15:49:34
I'm having problems using PHP SimpleXMLElement and simpleSMLToArray() function to parse a SOAP Response. I'm getting the SOAP response from my SOAP Server just fine. I'm writing both the SOAP Client and Server in this case. I'm using NuSoap for the server. To me, the soap response looks perfect, but the PHP5 Soap Client doesn't seem to parse it. So, as in the past, I'm using SimpleXMLElement and the function simpleXMLToArray() from PHP.NET ( http://php.net/manual/en/book.simplexml.php ), but can't seem to get an array. <SOAP-ENV:Envelope SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap