simplexml

Change manifest.plist values in PHP [duplicate]

家住魔仙堡 提交于 2019-12-11 18:22:12
问题 This question already has answers here : edit XML with simpleXML (4 answers) Closed 6 years ago . I have a manifest.plist file (come from Apple). This is an XML file. Here's an exemple of the structure : <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>id</key> <string>3214</string> <key>name</key> <dict> <key>en</key> <string>Hello World</string> <key>jp</key>

Basic mathematics in PHP Simplexml

て烟熏妆下的殇ゞ 提交于 2019-12-11 18:09:29
问题 The code below is in PHP and returns prices from a XML response file. $price = $result->Items->Item->OfferSummary->LowestNewPrice->FormattedPrice; //lowest new price $listPrice = $result->Items->Item->Offers->Offer->OfferListing->Price->FormattedPrice; //list price If I echo $price or $listPrice it works I wish to get the difference between the two prices but I am getting NULL if I do $savings = $listPrice - $price; or $savings = ($listPrice - $price); Any assistance is welcome 回答1: You're

Simplexml_load_file empty array

不打扰是莪最后的温柔 提交于 2019-12-11 17:51:25
问题 I try to load this document: $url = "http://en.wikipedia.org/w/api.php?action=query&titles=Electrophoresis&prop=langlinks&lllimit=500"; When I run it in browser, everything is fine. When I do this: ini_set('user_agent', 'XX123456789 (localhost; myemailaddress)'); //sets info for authentication $content = file_get_content($url); var_dump($content); It return the same xml document as my browser show. However when I try to $content_arrays = Simplexml_load_file($content); echo '<pre>', print_r(

Parse XML with multiple namespace to JSON - PHP

独自空忆成欢 提交于 2019-12-11 17:05:41
问题 I want to access the XML and parse it as JSON. <?xml version='1.0' encoding='UTF-8'?> <soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:ser='http://service.billing.org/'> <soapenv:Header /> <soapenv:Body> <ser:processTrans> <xmlValue> <![CDATA[ <ebpacket> <head> <packettype> UserAuthorization</packettype> <staffcode> ePay_UserName </staffcode> <pwd> ePay_Password </pwd> </head> <body> <email> _username </email> <loginpwd> _password </loginpwd> <deviceid>

Using cURL and simpleXMLElement to extract data. How do I get the value of the XML element after XPATH?

耗尽温柔 提交于 2019-12-11 16:33:08
问题 I am having some problems extracting the data I want from a SimpleXMLElement object. Here is the basics of the code I am using: curl_setopt( $ch, CURLOPT_URL, $URL ); $html = curl_exec( $ch ); $html = $tidy->parseString( $html, $tc, 'utf8' ); $tidy->cleanRepair(); $html = $tidy->body()->value; $xml = new SimpleXMLElement( $html ); $xml = $xml->xpath( "//ul[@id='wxoptions']/li[3]/a" ); //Your XPATH print_r( $xml ); This navigates to the correct HTML element I want, but prints: Array ( [0] =>

Grabbing a Specific Part of the Previous / Next Nodes

若如初见. 提交于 2019-12-11 16:26:11
问题 I am looping through a XML file with SimpleXML and trying to pull a specific piece of data (specifically, the series->displayname attribute) from the Previous and Next nodes each time. Here is a sample of the XML structure: <comic> <id>117</id> <index>1</index> <mainsection> <pagecount>33</pagecount> <series> <displayname>Amazing Story</displayname> <sortname>Amazing Story</sortname> </series> </mainsection> </comic> <comic> <id>102</id> <index>1</index> <mainsection> <pagecount>33</pagecount

Parsing XML from URL using SimpleXML

懵懂的女人 提交于 2019-12-11 15:24:20
问题 I'm trying to echo the XML content at this URL but I'm having difficulty. Here's what I have so far: $url = "GetVideosServlet?queryId=1"; $xml = simplexml_load_file($url); $value = (string) $xml->results->item[0]->id; echo $value; I keep getting the error that I'm trying to get the property of a non-object. But I was under the impression simplexml_load_file converts my XML string INTO an object?? If anyone could show me how to echo out any of the content, I'd be very grateful. 回答1: I think

SimpleXml conditional

谁说胖子不能爱 提交于 2019-12-11 15:06:41
问题 Hi I need to filter the xml that was given to me base on the following conditions ex. category needs to be Transportation, package needs to be Good and the last one item needs to have been publish today only. here is the sample xml <item> <category>Transportaion</category> <package>Good</package> <date>2018-04-17 17:10:46</date> <title>Item sample 1</title> <description>This is a sample</description> </item> <item> <category>Wanted</category> <package>Good</package> <date>2018-04-17 18:03:46<

How to drill into SOAP Namespaces with SimpleXML & PHP [duplicate]

天涯浪子 提交于 2019-12-11 14:46:25
问题 This question already has an answer here : Reference - how do I handle namespaces (tags and attributes with colon in) in SimpleXML? (1 answer) Closed last year . All, I am trying to access element ebl:RequesterCredentials in a SOAP response but having no success so far. I am using PHP SimpleXML. The issue for me at least is registering the ebl namespace - All I am getting in the response is this: xmlns=”urn:ebay:apis:eBLBaseComponents” I Tried this: $r = $xml->registerXPathNamespace("ebl",

last.fm API pagination

五迷三道 提交于 2019-12-11 13:53:32
问题 I'm creating a last.fm/ google maps mashup, plotting gig map markers for whatever city you search for. A last.fm API response is like this: <events location="New York" page="1" totalpages="105" total="1050"> <event> <id>640418</id> <title>Nikka Costa</title> <artists> etc. Currently, you can search for Edinburgh, for example - and it will bring back the first 10 gigs coming soon. I'm using PHP and simple XML to return the results. I want to add pagination - so first 10 gigs would be page 1; I