simplexml

How to delete an element from an XML tree where attribute is specific string in Simple XML PHP

Deadly 提交于 2019-12-08 04:58:54
问题 So I want to delete a child from an XML string where an attribute is a specific value. For Example: <xml> <note url="http://google.com"> Values </note> <note url="http://yahoo.com"> Yahoo Values </note> </xml> So how would I delete the note node with attribute http://yahoo.com as the string for the URL? I'm trying to do this in PHP Simple XML Oh and also I'm loading it in as an XML Object with the SimpleXML_Load_String function like this: $notesXML = simplexml_load_string($noteString['Notes']

How to parse an XML node with a colon tag using PHP

旧时模样 提交于 2019-12-08 02:08:23
问题 I am trying to fetch the value of the following nodes from [this URL (takes quite some time to load)][1]. The elements I'm interested in are: title, g:price and g:gtin The XML starts like this: <rss xmlns:g="http://base.google.com/ns/1.0" version="2.0"> <channel> <title>PhotoSpecialist.de</title> <link>http://www.photospecialist.de</link> <description/> <item> <g:id>BEN107C</g:id> <title>Benbo Trekker Mk3 + Kugelkopf + Tasche</title> <description> Benbo Trekker Mk3 + Kugelkopf + Tasche Das

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

别说谁变了你拦得住时间么 提交于 2019-12-08 01:00:59
问题 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

Parse iTunes RSS Atom feed with PHP?

和自甴很熟 提交于 2019-12-08 00:14:02
问题 Trying to parse an iTunes Atom feed with a PHP script. If you visit the iTunes RSS Generator, you can generate an Atom feed like this: http://itunes.apple.com/us/rss/topsongs/limit=10/genre=16/explicit=true/xml which gives an iTunes RSS feed result like this: <?xml version="1.0" encoding="utf-8"?> <feed xmlns:im="http://itunes.apple.com/rss" xmlns="http://www.w3.org/2005/Atom" xml:lang="en"> <id>http://itunes.apple.com/us/rss/topsongs/limit=10/genre=16/explicit=true/xml</id><title>iTunes

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

别来无恙 提交于 2019-12-07 21:01:47
问题 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,

Get specific node in xml?

喜你入骨 提交于 2019-12-07 18:48:43
问题 my xml is structured as follow: <?xml version="1.0" ?> <users> <user> <name> foo </name> <token> jfhsjfhksdjfhsjkfhksjfsdk </token> <connection> <host> localhost </host> <username> root </username> <dbName> Test </dbName> <dbPass> 123456789 </dbPass> </connection> </user> <user> ... same structure... </user> </users> I made this code that iterate through all xml node: function getConString($node) { $item = file_get_contents($_SERVER['DOCUMENT_ROOT'] . "con"); $nodes = new SimpleXMLElement(

Parsing a XML file using simplexml_load_file return empty object

*爱你&永不变心* 提交于 2019-12-07 14:50:01
问题 <?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<

simpleXML get node child based on attribute [duplicate]

限于喜欢 提交于 2019-12-07 13:29:02
问题 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

php: parsing table structure with SimpleXML

☆樱花仙子☆ 提交于 2019-12-07 11:14:51
问题 I'm trying to read in an xml file that for some reason has been modeled in a table structure like so: <tr id="1"> <td name="Date">10/01/2009</td> <td name="PromoName">Sample Promo Name</td> <td name="PromoCode">Sample Promo Code</td> <td name="PromoLevel" /> </tr> This is just one sample row, the file has multiple <tr> blocks and it's all surrounded by <table> . How can I read in the values, with all of the lines being named <td> name ? 回答1: You could use simpleXML with an XPath expression.

PHP: send POST request then read XML response?

╄→гoц情女王★ 提交于 2019-12-07 08:14:00
问题 I'm trying to write a PHP script that sends a POST request to a remote server, then parses the XML response. I can do the POST request, but am having difficulty (from other SO questions) working out how to parse the XML response. My current code gives me: Warning: simplexml_load_file() [function.simplexml-load-file]: I/O warning : failed to load external entity "1" in /Users/simon/usercreate.php on line 46 - the simplexml_load_file($response) line. I'm working on a local server, not sure if