simplexml

How to get SVG tag content with PHP

折月煮酒 提交于 2019-12-06 05:54:47
问题 I would like to get SVG tag content with PHP. test.svg: <?xml version="1.0" encoding="utf-8"?> <!-- comment --> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="202.5px" height="226.084px" viewBox="0 0 202.5 226.084" enable-background="new 0 0 202.5 226.084" xml:space="preserve"> <g> <path d="M0,13.628c47.7940,13

SimpleXML returning multiple objects, how can I get the data?

℡╲_俬逩灬. 提交于 2019-12-06 05:22:11
I'm using simpleXML to parse this xml file . It's a feed I'm using to access the YouTube API. I want to embed the most recent video in an object and display the next four thumbnails. So I'm using simplexml_load_file on this, going using a foreach loop to access the values in each feed. I can access the values no problem, but I run into the problem that it stores each video in a separate SimpleXMLElement Object . I don't have any control over which object I'm accessing as they are not stored in an array. So I can't get, say, $thumb[4] or $entry[4]->thumb . I tried to use SimpleXMLIterator , but

PHP SimpleXML Values returned have weird characters in place of hyphens and apostrophes

淺唱寂寞╮ 提交于 2019-12-06 05:16:39
I have looked around and can't seem to find a solution so here it is. I have the following code: $file = "adhddrugs.xml"; $xmlstr = simplexml_load_file($file); echo $xmlstr->report_description; This is the simple version, but even trying this any hyphens r apostrophes are turned into: ^a (euro sign) trademark sign. Things I have tried are: echo = (string)$xmlstr->report_description; /* did not work */ echo = addslashes($xmlstr->report_description); /* yes I know this doesnt work with hyphens, was mainly trying to see if I could escape the apostrophes */ echo = addslashes((string)$xmlstr-

get image src from <content:encoded> [duplicate]

为君一笑 提交于 2019-12-06 04:19:05
This question already has answers here : How to parse CDATA HTML-content of XML using SimpleXML? (2 answers) Closed 5 years ago . Im trying to get an img url from <content:encoded> and inserting the url into my DB But i can't seem to get correct information from the xml file- or is it not possible to retrive the data with simpleXML? This is my XML <item> <title>Movietitle</title> <content:encoded><![CDATA[<p> <img class="aligncenter wp-image-22085" src="movie-poster-694x1024.jpg" alt="Predestination 2014" width="475" height="701" /></p> <p><span id="more-22087"></span></p> <p> <a href="http:/

Getting an array from object using SimpleXMLElement

蹲街弑〆低调 提交于 2019-12-06 03:34:06
I'm having some problems getting the array in these objects. When I print_r(), the following code is printed. $message_object is the name of the object. SimpleXMLElement Object ( [header] => SimpleXMLElement Object ( [responsetime] => 2012-12-22T14:10:09+00:00 ) [data] => SimpleXMLElement Object ( [id] => Array ( [0] => 65233 [1] => 65234 ) [account] => Array ( [0] => 20992 [1] => 20992 ) [shortcode] => Array ( [0] => 3255 [1] => 3255 ) [received] => Array ( [0] => 2012-12-22T11:04:30+00:00 [1] => 2012-12-22T11:31:08+00:00 ) [from] => Array ( [0] => 6121843347 [1] => 6121820166 ) [cnt] =>

Retrieving CDATA contents from XML using PHP and simplexml

帅比萌擦擦* 提交于 2019-12-06 03:15:02
问题 I have the following XML structure: <?xml version="1.0" ?> <course xml:lang="nl"> <body> <item id="787900813228567" view="12000" title="0x|Beschrijving" engtitle="0x|Description"><![CDATA[Dit college leert studenten hoe ze een onderzoek kunn$ <item id="5453116633894965" view="12000" title="0x|Onderwijsvorm" engtitle="0x|Method of instruction"><![CDATA[instructiecollege]]></item> <item id="7433550075448316" view="12000" title="0x|Toetsing" engtitle="0x|Examination"><![CDATA[Opdrachten/werkstuk

Prettifying/Formatting output in SimpleXML

点点圈 提交于 2019-12-05 23:15:36
I have this simplexml script i'm using to post data entered from a form. $xml = simplexml_load_file("links.xml"); $sxe = new SimpleXMLElement($xml->asXML()); $person = $sxe->addChild("link"); $person->addChild("title", "Q: ".$x_title); $person->addChild("url", "questions_layout.php#Question$id"); $sxe->asXML("links.xml"); and when it comes out it looks like this on one line: <link><title>Alabama State</title><url>questions_layout.php#Question37</url></link><link><title>Michigan State</title><url>questions_layout.php#Question37</url></link></pages> But i've tried the method found HERE and THIS

Parsing a XML file using simplexml_load_file return empty object

我怕爱的太早我们不能终老 提交于 2019-12-05 22:51:11
<?xml version="1.0" ?> <aws:UrlInfoResponse xmlns:aws="http://alexa.amazonaws.com/doc/2005-10-05/"> <aws:Response xmlns:aws="http://awis.amazonaws.com/doc/2005-07-11"> <aws:OperationRequest> </aws:OperationRequest> <aws:UrlInfoResult> <aws:Alexa> <aws:TrafficData> <aws:DataUrl type="canonical">google.com/</aws:DataUrl> <aws:Rank>1</aws:Rank> </aws:TrafficData> </aws:Alexa> </aws:UrlInfoResult> <aws:ResponseStatus xmlns:aws="http://alexa.amazonaws.com/doc/2005-10-05/"> <aws:StatusCode>Success</aws:StatusCode> </aws:ResponseStatus> </aws:Response> </aws:UrlInfoResponse> All i want to parse is

simpleXML get node child based on attribute [duplicate]

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-05 21:15:12
This question already has answers here : SimpleXML: Selecting Elements Which Have A Certain Attribute Value (2 answers) Implementing condition in XPath [duplicate] (2 answers) Closed 6 years ago . I am trying to parse out the value of a node I am referencing by one of its attributes. but I am not sure of the syntax XML: <data> <poster name="E-Verify" id="everify"> <full_image url="e-verify-swa-poster.jpg"/> <full_other url=""/> </poster> <poster name="Minimum Wage" id="minwage"> <full_image url="minwage.jpg"/> <full_other url="spa_minwage.jpg"/> </poster> </data> here is where I want to get

SimpleXML - Cannot get attributes of first tag

为君一笑 提交于 2019-12-05 20:08:49
I am trying to read the attributes of the first tag of an XML. Here's the XML structure <myxml timestamp="1301467801"> <tag1>value1</tag1> <tag2>value2</tag2> … </myxml> And here's how I try to get the timestamp attribute (tried 2 approaches, listing them both here, none works) $timestamp = $xml->myxml->attributes()->timestamp; //gives Node no longer exists warning if($xml->myxml && $xml->myxml->attributes()){ //Doesn't enter this loop $arr = $xml->myxml->attributes(); $timestamp = $arr['timestamp']; } Can someone please let me know how I can get the attribute's value? Thanks. It's because