Forum Moderators: coopster
I have tried using CDATA unsuccessfully, entering <br /> tags on their own in the text seem to be ignored by the parser, so am not sure. There must be a tried and true method of including a paragraph of text and retrieving the data using PHP and XML?
Does anyone have any ideas or solutions to share with the community?
When a user post the form, I want the following:
$text = $_POST['textfield']; //gets the exact entry from form
...then I want to insert it into and XML file using SimpleXML which I have achieved, but I want to make sure any new lines etc are maintained and the code is XHTML compliant for the insertion into the XML node. i.e.
$text = line01
line02
line03;
I need to be able to extract this from the xml. It is for a blog comments area. I need the comments to appear as they were entered, but just stored in xml, not a database.
Thanks.
$text = $xml->addChild("text", [url=http://www.php.net/htmlentities]htmlentities[/url](nl2br($_POST['info'])));
And then when it comes to echoing, the following:
echo [url=http://www.php.net/html_entity_decode]html_entity_decode[/url]($xml->text[1]);
See how that works out for you :)
I have noticed with the solution above, it seems that when I download the XML file from the server, it only displays half of the xml elements. They show up fine when I run the application, but when downloaded, they are all on the one line when viewed in a text editor, and stop half way through the document.
Is there an answer to this weirdness?
$new->addChild('content', $content);
Is there a function to edit XML documents tag by tag with the ability to add a /n after a closing tag?