simplexml

modifying xml document using php

hello everyone , i have an xml file "Machine.xml" it contains: <Parameter name="host" value="localhost"/> <Parameter name="port" value="5900"/> i would like to change both parameters values using a php script... how can i do that? i mean i want the script to change host's value for example to : value="7.3.4.5" and port value to...

Accessing XML content via PHP using SimpleXML

I am working with the XML file string below and I've tried a number of methods to try and get access to certain parts of the XML contents. Please see the code after the XML file below for my attempt: <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org...

How can I move XML elements with PHP's SimpleXML?

How can I move an xml element elsewhere in a document? So I have this: <outer> <foo> <child name="a"/> <child name="b"/> <child name="c"/> </foo> <bar /> </outer> and want to end up with: <outer> <foo /> <bar> <child name="a"/> <child name="b"/> <child name="c"/> ...

SimpleXML and PHP XPath expression not returning correct data

The following PHP code: <html> <?php $name = Secrezy; $server = Sunstrider; $raidurl='http://eu.wowarmory.com/character-achievements.xml?r='.$server.'&amp;cn='.$name.'&amp;c=168'; print_r($raidurl); // This is to check if the link is valid. Follow the link printed here and you should find a valid XML page echo "<br>"; $xmlraid =...

Bulletproofing SimpleXMLElement

Everyone knows that we should always use DOM techniques instead of regexes to extract content from HTML, but I get the feeling that I can never trust the SimpleXML extension or similar ones. I'm coding a OpenID implementation right now, and I tried using SimpleXML to do the HTML discovery - but my very first test (with alixaxel.myopenid...

SimpleXml problems accessing xml nodes

Hello Guys, i have serious problems accessing nodes of a specific xml file: http://write.fm/cqsmrf5 with print_r i get the following result: SimpleXMLElement Object ( [RecordSet] => SimpleXMLElement Object ( [@attributes] => Array ( [dataSource] => testdatabase ...

simplexml_load_file() speed factors.

Hi, I'm working on a web-app, in which each user has multiple non-local XML files that are downloaded and parsed via SimpleXML each page (re)load. Each request takes a little less than a second on average, however with more than five or six files (which is likely), the load time is quite noticeable. So my question is what factors go into...

How to save an XML file on the web server using PHP?

I am a beginner in PHP and I know nothing about XML manipulation. I am working on a Google CSE annotation XML shown below: <?xml version="1.0" encoding="UTF-8" ?> - <Annotations> - <Annotation about="http://sanspace.in/"&gt; <Label name="_cse_byxamvbyjpc" /> </Annotation> - <Annotation about="http://blog.sanspace.in/"&gt; <Lab...

How to serialize a Map<String, String> using Simple XML?

How would you go about serialising a Map using simple XML so that it looks something like: <elem foo="value">key</elem> Instead of the normal <elem foo="key">value</elem> (The map is one to many, and since this will be edited by humans, I wanted it to be clearer.) [EDIT]: Doesn't Fix. ...

Updating a node value with PHP's simpleXML and xpath not working

Hello everyone! I have the following code inside a class: $tmp= $this->Xml->xpath("/page/text[@id='$this->Id']"); $tmp[0]= $this->Text; echo $tmp[0]; echo $this->Xml->asXml(); $this->Xml->asXML($this->FileName); //save XML the problem is "echo $tmp[0]" prints the updated text while $this->Xml->asXml() still contains the old node value...

Help accessing xml attribute in php

Hi, I'm new to php and coding in general. I'm trying to parse xml from a remote device and access specific value data. I would like to display group 9 probe 1 value for example and I cannot get it to work. Any tips? Here is the xml: <?xml version="1.0" encoding="ISO-8859-1" ?> - <Device id="S10011" hb="1935"> <Group id="1" /> ...

How to pull data from xml and break it in pages (pagination)

Hey everyone, I am using simplexml to pull data from an external xml source. I have got values even for limiting the number of results to display. I thought I could paginate with a simple query within the URL, something like "&page=2" but it is not possible as far as documentation shows. I downloaded a pagination class intended to use w...

XPath Node to String

How can I select the string contents of the following nodes: <span class="url"> word <b class=" ">test</b> </span> <span class="url"> word <b class=" ">test2</b> more words </span> I have tried a few things //span/text() Doesn't get the bold tag //span/string(.) is invalid string(//span) only selects 1 node I am using ...

How to get an attribute with SimpleXML?

Hello, I'm using simplexml_load_file($path_xml_file), it works good! If I do print_r($xml) it prints: SimpleXMLElement Object ( [@attributes] => Array ( [Message] => Login Successful [Token] => 11111111111 [DataFormat] => CSV ) ) How Can I get "token" value? Thank you! ...

Adding child nodes using SimpleXML

Hello all. I have an XML document and want to insert a new node at a specific spot using SimpleXML. The original XML is this: <epp xmlns="urn:ietf:params:xml:ns:epp-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:ietf:params:xml:ns:epp-1.0 epp-1.0.xsd" > <command> <create> <domain...

How to loop a SimpleXML object?

Hello everybody! I download a webpage with a XML code: $xml = simplexml_load_file($page); The results are: SimpleXMLElement Object ( [@attributes] => Array ( [Message] => Success [Date] => 0001-01-01T00:00:00 ) [FUNDAMENTALS] => SimpleXMLElement Object ( [FUNDAMEN...

PHP simpleXML: load string as node returns blank? (simplexml_load_string)

I'm trying to add a child to an XML-node by loading a string as an xml-node, but for some reason it returns an empty value ... // Load xml $path = 'path/to/file.xml'; $xml = simplexml_load_file($path); // Select node $fields = $xml->sections->fields; // Create new child node $nodestring = '<option> <label>A label</label> ...

SimpleXML: append one tree to another

Hello, I have to XML trees and would like to add one tree as a leaf to the other one. Apparently: $tree2->addChild('leaf', tree1); doesn't work, as it copies only the first root node. Ok, so then I tought I would traverse the whole first tree, adding every element one by one to the second one. But consider XML like this: <root> ...

How to remove a node if it exists with simpleXML

So I know the exact path the node I would be attempting to remove. I am iterating through several xml files to update some of the content. In order to add some of the new content in, I must first delete the content that already exists. Here is the code I attempted to use, but I'm receiving a Parse error: syntax error, unexpected T_UNS...

How to save changed SimpleXML object back to file?

So, I have this code that searches for a particular node in my XML file, unsets an existing node and inserts a brand new child node with the correct data. Is there a way of getting this new data to save within the actual XML file with simpleXML? If not, is there another efficient method for doing this? public function hint_insert() { ...