simplexml

Access all children of a certain node with simplexml and php

僤鯓⒐⒋嵵緔 提交于 2019-12-11 04:38:57
问题 I have a question and the answer is sure simple, but it just lacks of understanding from my side. I have a xml file with following look (short example) <item id="1234"> <property name="country_id"> <value>4402</value> </property> <property name="rc_maintenance_other"> </property> <property name="claim_right_shareholder"> </property> <property name="charges_other"> </property> <property name="other_expenses_heating"> </property> <property name="unpaid_bills_amount"> </property> <property name=

XML Data Cleanup Before Calling SimpleXML

半腔热情 提交于 2019-12-11 04:28:34
问题 This should be simple but it's been eluding me. We have a web service written in PHP that parses an XML payload that comes in as a POST, so the XML payload is contained in a $_POST variable. The service finds the POST var that looks like it has XML and then uses simplexml_load_string to load it up. It seems like whenever there are quotes in the data like <element>this is a "test"</element> or this <BuyerItemDesc>Customer's Serial Number</BuyerItemDesc> the load fails. My question is what's

php and simpleXml - how to change node contents

浪尽此生 提交于 2019-12-11 04:15:53
问题 I'm trying to change the contents of a node in an XML file using simpleXML. I know that the variable for the new node-contents contains the right stuff, but for some reason the file isn't changed when it is saved. I'm probably missing something basic, because I'm new to simpleXML. Here is the whole php script: <?php $doc=$_REQUEST["book"]; $div1=$_REQUEST["div1"]; $div2=$_REQUEST["div2"]; if ($div1=="") $div1=$_REQUEST["chapter"]; if ($div2=="") $div2=$_REQUEST["verse"]; $div3=$_REQUEST["div3

PHP Simplexml failing on localhost

此生再无相见时 提交于 2019-12-11 04:09:38
问题 I'm editing a mashup of mine where I fetch last.fm data through their API (xml). For some reason, my localhost can't connect to the file: it gives the following error. failed to open stream: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. in C:\Web\Apache\Apache2\htdocs\soctfm\user.php on line 35 and I/O warning : failed to load external entity The problem,

Using PHP to manage GMail Mail Filter XML Files

时间秒杀一切 提交于 2019-12-11 03:58:46
问题 Since GMail made it possible to import and export the mail filters, I'd like to manage the XML files that are exported from GMail using a PHP script, as there are some known issues with the number of characters in the search filters. I've found the simplexml_load_file function in PHP, and have performed var_dump() against the performed export, but I now don't seem to be able to access the apps namespace within the generated XML file. Following various pages within the PHP manual, I created

SimpleXML loop works but breaks half way through

我的梦境 提交于 2019-12-11 03:31:49
问题 I have a loop going through results from a youtube feed and it works fine but towards the end it fails with the error: Warning: main() [function.main]: Node no longer exists in ../youtubereader.php on line 8 Warning: main() [function.main]: Node no longer exists in .../youtubereader.php on line 8 Fatal error: Call to a member function attributes() on a non-object in .../youtubereader.php on line 9 My code is: <?php error_reporting(E_ALL); $feedURL = 'http://gdata.youtube.com/feeds/api/users

php simplexml_load_file - not able to see in print_r

早过忘川 提交于 2019-12-11 03:04:43
问题 I am new to simplexml parser in PHP. I have run the examples that I have found and they work as advertised. I can't get it to work with my program though. I have searched in here for hours. I have an XML file called core.xml (note that the node tags have colons in): <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl

Get XML tags from asXML()

北战南征 提交于 2019-12-11 02:38:46
问题 I am parsing through an XML document and getting the values of nested tags using asXML() . This works fine, but I would like to move this data into a MySQL database whose columns match the tags of the file. So essentially how do I get the tags that asXML() is pulling text from? This way I can eventually do something like: INSERT INTO db.table (TheXMLTag) VALUES ('XMLTagText'); This is my code as of now: $xml = simplexml_load_file($target_file) or die ("Error: Cannot create object"); foreach (

Xpath problem, getting the id(attribute) of a element, if you know the title of the element

纵然是瞬间 提交于 2019-12-11 02:38:14
问题 This is my XML file, and i want to know how to get the ID of the article when you know what the title is. Is this possible using Xpath? XML file: <Articles> <Article ID="1"> <title>test</title> <content>test</content> </Article> </Articles> Php code: $dom = new DOMDocument; $dom->load("Articles.xml"); $xp = new DOMXPath($dom); $id = $xp->evaluate('string(/Articles/Article[title="test"]/@ID)'); var_dump($id); Kind regards, User. 回答1: As long as you are using SimpleXml, you cannot return the ID

simpleXML: parsing XML to output only an elements attributes

烂漫一生 提交于 2019-12-11 02:15:41
问题 I'm attempting to parse an XML file using simpleXML, but I keep running into issues (mind you I'm a PHP noob.) This is the structure of the XML file.. (Naming convention used for readability.) <World> <Continent Name="North America" Status="" > <Country Name="United States of America" Status=""> <City Name="New York" Status="" /> <City Name="Chicago" Status="" /> </Country> </Continent> </World> All of the data is set as attributes (not my decision.) I need to be able to output the name