[ create a new paste ] login | about

Link: http://codepad.org/LSo9ufEE    [ raw code | output | fork ]

PHP, pasted on Dec 10:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php

$xmlstr = <<<XML
<?xml version="1.0" encoding="ISO-8859-1"?>
<elements>
    <element>
        <title>Test Story 1</title>
        <tagline>This is the first test story.</tagline>
        <startdate>12/10/2012</startdate>
        <enddate>12/20/2012</enddate>
        <file/>
        <link>http://www.google.com</link>
    </element>
</elements>
XML;
$xml = simplexml_load_string($xmlstr);
$editEntry = new SimpleXMLElement($xml->asXML()); 
$editEntry->element[0]->title = "New Title";
echo($editEntry->asXML());

?>


Output:
1
2
3
4
5
6
7
8
9
10
11
<?xml version="1.0" encoding="ISO-8859-1"?>
<elements>
    <element>
        <title>New Title</title>
        <tagline>This is the first test story.</tagline>
        <startdate>12/10/2012</startdate>
        <enddate>12/20/2012</enddate>
        <file/>
        <link>http://www.google.com</link>
    </element>
</elements>


Create a new paste based on this one


Comments: