simplexml

Trying to Parse Only the Images from an RSS Feed

若如初见. 提交于 2019-12-02 04:38:29
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>http://mywebsite.com/</link> <description>Visit My Site</description> </image> <item> <title>Article One<

simpleXML and accented characters in PHP

自古美人都是妖i 提交于 2019-12-02 04:20:24
问题 I have written an XML file which is using the ISO-8859-15 encoding and most of the data within the feed is ran through htmlspecialchars(). I am then using simplyxml_load_string() to retrieve the contents of the XML file to use in my script. However, if I have any special characters (ie: é á ó) it comes out as "é á ó". The How can I get my script to display the proper special accented characters? 回答1: You’re probably using a different character encoding for you output than the XML data is

How can I display XML with whitespace formatting?

本小妞迷上赌 提交于 2019-12-02 04:07:34
I have a web page that builds an XML from an existing XML applying changes. I want to output the new XML file in a textarea as a preview. It displays any nodes that were present in the original XML with the proper whitespaces/formatting (indents and linebreaks) that the original XML had just fine, but any new nodes are all displayed on one line with no indents. Example: <original parent node> <original child>value</original child> </original parent node> <original parent node> <new child>value</new child><new child>value</new child><new child>value</new child><new child>value</new child><new

Extracting HTML from an XML file using simpleXML

纵饮孤独 提交于 2019-12-02 03:51:07
问题 I'm reading an xml file generated by a 3rd-party application that includes the following: <Cell> <Comment ss:Author="Mark Baker"> <ss:Data xmlns="http://www.w3.org/TR/REC-html40"><B><Font html:Face="Tahoma" html:Size="8" html:Color="#000000">Mark Baker:</Font></B><Font html:Face="Tahoma" html:Size="8" html:Color="#000000"> Comment 1 - No align</Font></ss:Data> </Comment> </Cell> What I'm trying to do is access the raw data from the Cell->Comment->Data element either "as is" or as an actual

PHP simplexml_load_file catch 403

走远了吗. 提交于 2019-12-02 03:48:03
I am using the following PHP: $xml = simplexml_load_file($request_url) or die("url not loading"); I use: $status = $xml->Response->Status->code; To check the status of the response. 200 bening everything is ok, carry on. However if I get a 403 access denied error, how do I catch this in PHP so I can return a user friendly warning? To retrieve the HTTP response code from a call to simplexml_load_file() , the only way I know is to use PHP's little known $http_response_header . This variable is automagically created as an array containing each response header separately, everytime you make a HTTP

What is happening when SimpleXML parses XML with special characters?

我怕爱的太早我们不能终老 提交于 2019-12-02 03:47:37
问题 I am trying to solve this problem I am having with my final output. The XML feed looks like this... <?xml version='1.0' encoding='utf-8'?> <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> <channel> <item> <title>TRON: Legacy, 2010 - ★★★</title> I would like to preserve the stars in the final output but my final output looks like this... TRON: Legacy, 2010 - ★★★ Here is the code I am using in PHP - $title = $item->title; $movieLink = $item->link; $xml = new SimpleXMLElement(

Node no longer exists using SimpleXML

纵然是瞬间 提交于 2019-12-02 03:42:46
问题 Trying to cache an xml file using the build in wordpress function called get_transient but I'm getting a php error: unserialize() [function.unserialize]: Node no longer exists //check the db to see if it exists ( get_transient is a WordPress function) if (false === ($response_xml = get_transient('stats_from_xml_feed'))){ $request_url = "http://example.com/feed.xml"; $request_url = urlencode($request_url); $response_xml = @simplexml_load_file($request_url); //kill request if connection problem

parse a SOAP XML response with Namespaces using PHP

喜欢而已 提交于 2019-12-02 03:33:19
问题 I have this ugly XML which has alot of namespaces on it, when I try to load it with simpleXML if i indicate the first namespace I'd get an xml object ,but following tags with other namespaces would not make it to the object. Here is the SOAP response <?xml version="1.0" encoding="utf-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas

display data from XML using php simplexml

两盒软妹~` 提交于 2019-12-02 02:53:43
I have a piece of XML which is as follows <records count="2"> <record> <firstname>firstname</firstname> <middlename>middlename</middlename> <lastname>lastname</lastname> <namesuffix/> <address> <street-number>demo</street-number> <street-pre-direction/> <street-name>demo</street-name> <street-post-direction/> <street-suffix>demo</street-suffix> <city>demo</city> <state>NY</state> <zip>demo</zip> <zip4>demo</zip4> <county>demo</county> </address> <phonenumberdetails> <phonenumber>demo</phonenumber> <listed>demo</listed> <firstname>demo</firstname> </phonenumberdetails> <dob day="" month="" year

parse a SOAP XML response with Namespaces using PHP

梦想的初衷 提交于 2019-12-02 02:23:58
I have this ugly XML which has alot of namespaces on it, when I try to load it with simpleXML if i indicate the first namespace I'd get an xml object ,but following tags with other namespaces would not make it to the object. Here is the SOAP response <?xml version="1.0" encoding="utf-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:ns8502="http://tempuri.org"> <SOAP-ENV:Header> <Interface PartnerID=