Warning: DOMDocument::loadXML() [function.DOMDocument-loadXML]: AttValue: " or ' expected in Entity, line: 2 in C:\WAMP\www\SCEV\validate_sce.php on line 17
Warning: DOMDocument::loadXML() [function.DOMDocument-loadXML]: attributes construct error in Entity, line: 2 in C:\WAMP\www\SCEV\validate_sce.php on line 17
Here's some code snippets:
index.html:
Code: Select all
<form action="validate_sce.php" method="post">
<label for="sceText">SCE Text: </label>
<textarea name="sceText" cols="120" rows="25"></textarea>
<br />
<br />
<label for="validateButton"> </label>
<input name="validateButton" type="submit" value="Validate" />
</form>
validate_sce.php:
Code: Select all
<?php
$sceText = $_POST["sceText"];
$sceText = str_replace( "\n", "", $sceText );
$sceText = str_replace( "\r", "", $sceText );
$sceText = "<root>\n" . $sceText . "\n</root>";
$dom = new DOMDocument;
$dom->loadXML( $sceText );
if ( !$dom ) {
echo "Error while parsing the SCE Text.";
exit;
} // end if
$s = simplexml_import_dom( $dom );
if ( $s = FALSE ) {
echo "<h1>Something went wrong when importing the DOM.</h1><br />";
} // end if
echo "<h3>" . $s->Server["password"] . "</h3>";
?>
The warnings are about the '$dom->loadXML( $sceText );' line.
Any ideas? Users would be posting multi-line, well-formed XML code into the text area for validation.
I remember having trouble with multi-line data in text areas before, but I ignored it. Not sure if that's the problem here though.
Any help is greatly appreciated.