simplexml

Trying to Parse Only the Images from an RSS Feed

狂风中的少年 提交于 2019-12-04 05:13:07
问题 First, I am a php newbie. I have looked at the question and solution here . For my needs however, the parsing does not go deep enough into the various articles. A small sampling of my rss feed reads like this: <channel> <atom:link href="http://mywebsite.com/rss" rel="self" type="application/rss+xml" /> <title>My Web Site</title> <description>My Feed</description> <link>http://mywebsite.com/</link> <image> <url>http://mywebsite.com/views/images/banner.jpg</url> <title>My Title</title> <link

XML with varying amount of child nodes for each parent node

眉间皱痕 提交于 2019-12-04 05:06:37
问题 So I have XML in the following format which I am reading from file 'test.xml' <XML> <Agent ID="ABC123"> <Property> <Code>XYZ</Code> <Name>Hotel 1</Name> </Property> <Property> <Code>237</Code> <Name>Hotel 2</Name> </Property> <Property> <Code>213</Code> <Name>Hotel 3</Name> </Property> </Agent> <Agent ID="DEF456"> <Property> <Code>333</Code> <Name>Hotel 4</Name> </Property> <Property> <Code>23423</Code> <Name>Hotel 5</Name> </Property> </Agent> <Agent ID="GHI789"> <Property> <Code>45345</Code

Selecting the children of first result using xpath

ぐ巨炮叔叔 提交于 2019-12-04 04:08:34
问题 I have a piece of XML where the same information can appear as a child of different nodes. Such as : <root> <category id=1> <product id="ABC123" > <sizes> <size name="S"/> <size name="M"/> <size name="L"/> <size name="XL"/> <size name="2XL"/> <size name="3XL"/> </sizes> </product> </products> </category> <category id=2> <products> <product id="ABC123" > <sizes> <size name="S"/> <size name="M"/> <size name="L"/> <size name="XL"/> <size name="2XL"/> <size name="3XL"/> </sizes> </product>

PHP, json_encode, json_decode of SimpleXML Object

本小妞迷上赌 提交于 2019-12-04 03:47:18
问题 A function in my application does the following: Capture Web Page using Snoopy Load result into DOMDocument Load DOMDocument into Simple XML Object Run XPath to isolate section of document required json_encode the result and save to database for later use. My problem arises when recovering this block from the database, and decoding it. I can see the @attributes when I var_dump the object, but cannot find a combination of commands that allows me to access them. Error message is: Fatal error:

Create XML with xmlns:xlink attribute in a node

廉价感情. 提交于 2019-12-03 21:58:59
问题 i'm trying to add generate an output like this: <mets .... xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.loc.gov/METS/ http://www.loc.gov/standards/mets/mets.xsd"> I can generate everything fine, but cannot add the xmlns:xlink attribute. The closest I get is: $this->xml = new SimpleXMLElement('<mets></mets>'); $mets->addAttribute("xlink:someName", "blabla", "http://www.w3.org/1999/xlink"); $mets->addAttribute(

OSM Data parsing to get the nodes with child

杀马特。学长 韩版系。学妹 提交于 2019-12-03 21:51:12
问题 I download Open Street Map data for a small region, I want to filter the data to get the nodes with special category. Here is sample of the OSM data <node id="505126369" lat="31.2933856" lon="34.2687443" user="JumpStart International" uid="125156" visible="true" version="1" changeset="2568758" timestamp="2009-09-22T13:05:10Z"/> <node id="505126372" lat="31.2682934" lon="34.2745680" user="JumpStart International" uid="125156" visible="true" version="1" changeset="2568758" timestamp="2009-09

How to remove SimpleXMLElement Object from php array

拥有回忆 提交于 2019-12-03 21:16:45
I have read xml file using simplexml_load_file php function. I have store xml data into php array but in some array its display array of xml like SimpleXMLElement Object ( [0] => some value ) When I am print xml data , its display properly but when I am assign xml value to php array its display as above xml object in array XML <data> <request> <type>City</type> <query>Anand, India</query> </request> <current_condition> <observation_time>08:55 AM</observation_time> <temp_C>28</temp_C> <temp_F>82</temp_F> <weatherCode>113</weatherCode> <weatherDesc>Sunny</weatherDesc> <windspeedMiles>9<

Adding a block of XML as child of a SimpleXMLElement object

流过昼夜 提交于 2019-12-03 20:27:20
问题 I have this SimpleXMLElement object with a XML setup similar to the following... $xml = <<<EOX <books> <book> <name>ABCD</name> </book> </books> EOX; $sx = new SimpleXMLElement( $xml ); Now I have a class named Book that contains info. about each book. The same class can also spit out the book info. in XML format akin the the above (the nested block).. example, $book = new Book( 'EFGH' ); $book->genXML(); ... will generate <book> <name>EFGH</name> </book> Now I'm trying to figure out a way by

Uncaught exception 'Exception' with message 'Serialization of 'SimpleXMLElement' is not allowed'

孤人 提交于 2019-12-03 17:52:02
问题 I am not sure why this is coming up. I am not serializing the XML, but my array that I created from an RSS feed (note this is just a snippet): $game_data = array ( 'sysreqos' => $game->systemreq->pc->sysreqos, 'sysreqmhz' => $game->systemreq->pc->sysreqmhz, 'sysreqmem' => $game->systemreq->pc->sysreqmem, 'sysreqdx' => $game->systemreq->pc->sysreqdx, 'sysreqhd' => $game->systemreq->pc->sysreqhd, ); Then I serialize it $some_var = serialize($game_data) and write to a text file fputs($fh,$some

How to keep DOMDocument from saving < as &lt

别等时光非礼了梦想. 提交于 2019-12-03 13:10:39
I'm using simpleXML to add in a child node within one of my XML documents... when I do a print_r on my simpleXML object, the < is still being displayed as a < in the view source. However, after I save this object back to XML using DOMDocument, the < is converted to < and the > is converted to > Any ideas on how to change this behavior? I've tried adding dom->substituteEntities = false; , but this did no good. //Convert SimpleXML element to DOM and save $dom = new DOMDocument('1.0'); $dom->preserveWhiteSpace = false; $dom->formatOutput = false; $dom->substituteEntities = false; $dom->loadXML(