i'm having a problem with
$xml2 = new DOMDocument;
$xml2->load($FilenamePost."/".$FilenameOfTh开发者_StackOverflow社区ePost.'.xml');
/* filename.xml */
$xpath2 = new DOMXPath($xml2);
$hrefs2 = $xpath2->evaluate("/page");
$Title = str_replace("-==single-quote==--"," " ",$Title);
$Title = str_replace('-==double-quote==--',' " ',$Title);
$Title = str_replace('"',' " ',$Title);
$Title = "Sssa "";
$href2 = $hrefs2->item(0);
$href2->setAttribute("PostTitle",$Title);
$xml2->save($FilenamePost."/".$FilenameOfThePost.'.xml');
/*
And when i try to write
"
in my xml, it keeps showing
"
*/
WHY IS THIS??? I cannot find a logical explication ...
Just do that:
$Title = str_replace("-==single-quote==--", ' " ',$Title);
$Title = str_replace('-==double-quote==--', ' " ',$Title);
And you will have your "
in xml.
You have to write "
directly, DomDocument takes care of escaping it.
$Title = "Sssa &";
...
...->setAttribute("PostTitle", $Title);
When saving, the PostTitle attribute will be properly escaped:
<... PostTitle="Sssa "" ...>
setAttribute() does escaping by default so you might need to use html_entity_decode() if the string is already escaped:
$href2->setAttribute("PostTitle", html_entity_decode($Title));
精彩评论