This is what I've got
$xml = $_POST["xml"];
$title = $_POST["title"];
$content = $_POST["content"];
$xmlDoc = $xml.".xml";
$edit = simplexml_load_file($xmlDoc);
$sxe = new SimpleXMLElement($edit->asXML());
$post = $sxe->addChild("post");
$post->addChild("title", $title);
$post->addChild("content", $content);
$sxe->asXML($xmlDoc);
My XML is something like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/css" href="style.css"?>
<flyer>
****This is where I want to add a new item*****
<post>
<title>title1</title>
<content>content1
</content>
</post>
<post>
<title>title2</title>
<content>content2
</content>
</post>
</flyer>
I've done this before with a text document but not with simpleXML.
Is there a way I can prepend it with out having to set the bottom as a variable and add it after I add the new post?
If there isn't an other way then that... How can I do that using simpleXML or DOM?
Thanks in advance! =)
Donald,
Thanks =)
I can do html =)
What I'm trying to do is php.
I'm trying to find out how to prepend data to a separate file (xml) based on a form a user submits.
The user populates the value of $title and $content when they submit the form.
I'm trying to put those two values in a <post> tag as the first item in xml.
$xml = $_POST["xml"];
$title = $_POST["title"];
$content = $_POST["content"];
$xmlDoc = $xml.".xml";
$edit = simplexml_load_file($xmlDoc);
$sxe = new SimpleXMLElement($edit->asXML());
$post = $sxe->addChild("post");
$post->addChild("title", $title);
$post->addChild("content", $content);
$sxe->asXML($xmlDoc);
My XML is something like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/css" href="style.css"?>
<flyer>
****This is where I want to add a new item*****
<post>
<title>title1</title>
<content>content1
</content>
</post>
<post>
<title>title2</title>
<content>content2
</content>
</post>
</flyer>
I've done this before with a text document but not with simpleXML.
Is there a way I can prepend it with out having to set the bottom as a variable and add it after I add the new post?
If there isn't an other way then that... How can I do that using simpleXML or DOM?
Thanks in advance! =)
Donald,
Thanks =)
I can do html =)
What I'm trying to do is php.
I'm trying to find out how to prepend data to a separate file (xml) based on a form a user submits.
The user populates the value of $title and $content when they submit the form.
I'm trying to put those two values in a <post> tag as the first item in xml.