I am trying upload xml file using simplexml_load_file but when in file is special character i'm getting an error ( There is everything alright without special character in it). First of all, I am using XML file from another program so i can't change it.
This is sample of xml:
<wuo>
<header>
<title>title1</title>
</header>
<body>
<lp>1</lp>
<sign>124.455</sign>
<text>sample text with & character</text> //<-- this is causing the problem
</body>
<body>
<lp>2</lp>
<sign>12556.455</sign>
<text>sample text 2</text>
</body>
</wuo>
My code:
if(isset($_POST["submit"]))
{
if(isset($_FILES['wuo']) && ($_FILES['wuo']['error'] == UPLOAD_ERR_OK))
{
if(!simplexml_load_file($_FILES['wuo']['tmp_name']))
{
// if file has special character in it this fires up
echo 'Error';
}
else
$file = simplexml_load_file($_FILES['wuo']['tmp_name']);
print_r($file);
/**
showing file to html etc... unimportant code for this case
**/
}
else
echo 'Error:' . $_FILES['wuo']['error'];
}
I know, I should do something before simplexml_load_file
but i don't know what exaclty. Or maybe I should use something else...
Btw: I don't need to secure it because this is only for me.