看板 PHP 關於我們 聯絡資訊
※ 引述《Clessin (Clemond)》之銘言: : Arrack大分享的方法經我測試真得是可行的方案,已順利的將UTF-8的中文 : 取代XML檔案中的變數符號,並透過browser輸出WORD檔給使用者, : 且檔案能順利開啟!再次感謝! 只是有個小小的疑問,為何一定要用像%1%這種 : 符號才能順利以中文字取代掉呢?我剛試過用<<title>>這種符號, : 反而無法取代,會讓下載回來的檔案都還是呈現原來<<title>>的樣子.... : 不知為何?感謝! 我在w3schools.com看到了這則教學資訊,在此自問自答一下,供未來跟我遇到 同樣問題的人參考: ---------------------------------------------- Entity References Some characters have a special meaning in XML. If you place a character like "<" inside an XML element, it will generate an error because the parser interprets it as the start of a new element. This will generate an XML error: <message>if salary < 1000 then</message> To avoid this error, replace the "<" character with an entity reference: <message>if salary &lt; 1000 then</message> There are 5 predefined entity references in XML: &lt; < less than &gt; > greater than &amp; & ampersand &apos; ' apostrophe &quot; " quotation mark 這就是為什麼我用<<title>>的符號,無法順利取代的原因! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.34.41.160
MOONRAKER:括號百百種,你啥不好用,偏要用<>... 06/06 10:49
Clessin:呵,因為原本是用rtf檔來做template檔,所以就用了<>符號 06/06 10:58
MOONRAKER:對喔,rtf要避開 [ ] 06/06 11:02