Javascript veya PHP kullanarak XML geçersiz karakterleri değiştirmek nasıl

0 Cevap php

Aşağıdaki için buraya yardıma mı ihtiyacınız var:

Koşu PHP, JavaScript, MySQL, XML.

1) Retrieving file from MySQL and stored it onto XML file.
2) Use javascript function to load XML file (that stored those data).
3) It produces invalid characters in XML file.

STEP 1 : Sample of the code in PhP -> Loading MySQL DB to store data onto XML file

$file= fopen("MapDeals2.xml", "w");
$_xml ="<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"; 
$_xml .="<MAP>\n";

while($row1_ThisWeek = mysql_fetch_array($result1_ThisWeek)) {
    $rRName =  $row1_ThisWeek['Retailer_Name'];
    $rRAddress = $row1_ThisWeek['Retailer_Address1'];
    $rRAddressPostCode = $row1_ThisWeek['Retailer_AddressPostCode1'];

//} commented out from the original


    $_xml .= "<DEAL>\n"; 
    $_xml .= "<DealDescription>" . $d_Description . "</DealDescription>\n";
    $_xml .= "<DealURL>" . $d_URL . "</DealURL>\n";
    $_xml .= "<DealRName>" . $rRName . "</DealRName>\n";
    $_xml .= "<DealRAddress>" . $rRAddress . "</DealRAddress>\n";
    $_xml .= "<DealRPostCode>" . $rRAddressPostCode . "</DealRPostCode>\n";
    $_xml .=  "</DEAL>\n";

} 


//} commented out from the original
$_xml .="</MAP>\n";
fwrite($file, $_xml);
fclose($file);

STEP 2 : Sample of the code in Javscript -> Loading XML file

xhttp.open("GET","Test2.xml", false);
xhttp.send("");
xmlDoc=xhttp.responseXML; 

var x=xmlDoc.getElementsByTagName("Employee");

parser = new DOMParser();
xmlDoc = parser.parseFromString("MapDeals2.xml", "text/xml");


for (i=0;i<x.length;i++)
{
//  alert ('Generating FOR loop');
  var d1 = x[i].getElementsByTagName("EmployeeDescription")[0].childNodes[0].nodeValue;
  var e1 = "<br></br>"; 
.
.
.


}

Yukarıda bir çözüm var mı? Yakında duymak için bekliyorum.

Şerefe

0 Cevap