xml中文乱码
谁知道下面的文件是什么编码?我读取中文时,总是乱码
<?xml version="1.0"?>
<report id="2tcB61Da2 ibd040112000"
user="bsp"
date="1131018911"
desc="Items - General (General)"
exp="No"
langlinked=" "
lmargin="0"
tmargin="2"
bmargin="2"
fmargin="-1"
plen="-1"
pwidth="132"
font="Small (17.1 cpi)"
cols="0"
fontfixed="No"
repexp="1"
helptxt="">
<displayformats>
<dateformat value="DDMMYY"/>
<c_dateformat value="YYYYMMDD"/>
<formatted_date value="YY:MM:DD"/>
<c_formatted_date value="YYYY:MM:DD"/>
<datesep value="-"/>
<timesep value=":"/>
<thousep value=","/>
<radixchar value="."/>
<overflow_ch value="#"/>
<display name="tcibd.sort.itm" difo = "%.37s"/>
<display name="tcitem" difo = "%.47s"/>
<display name="tccitg" difo = "%-6.6s"/>
<display name="tcitmt" difo = "%.14s"/>
</displayformats>
<user_info>
<locale value="CP936"/>
</user_info>
<body>
<emptyline/>
<emptyline/>
<row rc="1" layout="header.1.1"><e>Date</e><e>23-11-06</e><e>21:00</e><e>Asi</e><e>Items - General (General)</e><e>Page</e><e> 1</e></row>
<row rc="1" layout="header.1.2"><e>Hyva China </e><e>Sorted By</e><e>Item</e><e>Company</e><e>101</e></row>
<emptyline/>
<row rc="1" layout="header.1.4"></row>
<row rc="1" layout="header.1.5"><e>Item</e><e>Description</e><e>Item Type</e><e>Actual Type</e><e>Item Group</e><e>Item Type Spec.</e></row>
<row rc="1" layout="header.1.6"></row>
<row rc="1" layout="detail.1.1"><e> 1GRAM</e><e>1G 鍇|?/e><e>Purchased</e><e></e><e>PUR</e><e>?-璐鐋╂缁-</e><e>Not applicable</e></row>
<row rc="2" layout="detail.1.1"><e> 256MRAM</e><e>256M鍇|?/e><e>Purchased</e><e></e><e>PUR</e><e>?-璐鐋╂缁-</e><e>Not applicable</e></row>
<row rc="3" layout="detail.1.1"><e> 512MRAM</e><e>512M 鍇|?/e><e>Purchased</e><e></e><e>PUR</e><e>?-璐鐋╂缁-</e><e>Not applicable</e></row>
<row rc="4" layout="detail.1.1"><e> A-KEYBOARD</e><e>鍫敡楫?e><e>Purchased</e><e></e><e>PUR</e><e>?-璐鐋╂缁-</e><e>Not applicable</e></row>
<row rc="5" layout="detail.1.1"><e> AG-FAM</e><e>Agg Family</e><e>Purchased</e><e></e><e>PUR</e><e>?-璐鐋╂缁-</e><e>Not applicable</e></row>
<row rc="6" layout="detail.1.1"><e> AG1</e><e>Agg 1</e><e>Purchased</e><e></e><e>PUR</e><e>?-璐鐋╂缁-</e><e>Not applicable</e></row>
<row rc="7" layout="detail.1.1"><e> AG2</e><e>Agg 2</e><e>Purchased</e><e></e><e>PUR</e><e>?-璐鐋╂缁-</e><e>Not applicable</e></row>
<row rc="8" layout="detail.1.1"><e> APAPER</e><e>NotBad Paper</e><e>Purchased</e><e></e><e>PUR</e><e>?-璐鐋╂缁-</e><e>Not applicable</e></row>
<row rc="9" layout="detail.1.1"><e> BF-MAT</e><e>邋|叉?/e><e>Purchased</e><e></e><e>PUR</e><e>?-璐鐋╂缁-</e><e>Not applicable</e></row>
<row rc="10" layout="detail.1.1"><e> BF-PROD</e><e>邋|蹭骇?</e><e>Manufactured</e><e></e><e>MAN</e><e>?堕+犵|╂缁-</e><e>Not applicable</e></row>
<row rc="11" layout="detail.1.1"><e> BOOK</e><e>Book</e><e>Manufactured</e><e></e><e>MAN</e><e>?堕+犵|╂缁-</e><e>Not applicable</e></row>
<row rc="12" layout="detail.1.1"><e> BOX</e><e>妯绠?/e><e>Manufactured</e><e></e><e>MAN</e><e>?堕+犵|╂缁-</e><e>Not applicable</e></row>
<row rc="13" layout="detail.1.1"><e> BPAPER</e><e>Bad Paper</e><e>Purchased</e><e></e><e>PUR</e><e>?-璐鐋╂缁-</e><e>Not applicable</e></row>
<row rc="14" layout="detail.1.1"><e> CAR</e><e>杞﹁緗</e><e>Cost</e><e></e><e>FAM</e><e>?璧-浜?/e><e>Not applicable</e></row>
<row rc="15" layout="detail.1.1"><e> CPU</e><e>CPU</e><e>Purchased</e><e></e><e>PUR</e><e>?-璐鐋╂缁-</e><e>Not applicable</e></row>
<row rc="16" layout="detail.1.1"><e> CPU-2</e><e>CPU-2</e><e>Purchased</e><e></e><e>PUR</e><e>?-璐鐋╂缁-</e><e>Not applicable</e></row>
<row rc="17" layout="detail.1.1"><e> CRT</e><e>婢绀哄?/e><e>Purchased</e><e></e><e>PUR</e><e>?-璐鐋╂缁-</e><e>Not applicable</e></row>
<row rc="18" layout="detail.1.1"><e> E-MAT</e><e>Eng Material</e><e>Purchased</e><e></e><e>PUR</e><e>?-璐鐋╂缁-</e><e>Not applicable</e></row>
<row rc="19" layout="detail.1.1"><e> E-PROD</e><e>Eng Production</e><e>Manufactured</e><e></e><e>MAN</e><e>?堕+犵|╂缁-</e><e>Not applicable</e></row>
<row rc="20" layout="detail.1.1"><e> FI-PC</e><e>PC绯诲-</e><e>Manufactured</e><e></e><e>MAN</e><e>?堕+犵|╂缁-</e><e>Not applicable</e></row>
<row rc="21" layout="detail.1.1"><e> KEYBOARD</e><e>楫?e><e>Purchased</e><e></e><e>PUR</e><e>?-璐鐋╂缁-</e><e>Not applicable</e></row>
<row rc="22" layout="detail.1.1"><e> KIT</e><e>Sales Kit</e><e>Manufactured</e><e></e><e>MAN</e><e>?堕+犵|╂缁-</e><e>Not applicable</e></row>
<row rc="23" layout="detail.1.1"><e> KP1</e><e>Kit Part1</e><e>Purchased</e><e></e><e>PUR</e><e>?-璐鐋╂缁-</e><e>Not applicable</e></row>
<row rc="24" layout="detail.1.1"><e> KP2</e><e>Kit Part2</e><e>Purchased</e><e></e><e>PUR</e><e>?-璐鐋╂缁-</e><e>Not applicable</e></row>
<row rc="25" layout="detail.1.1"><e> MOUSE</e><e>榧犳?</e><e>Purchased</e><e></e><e>PUR</e><e>?-璐鐋╂缁-</e><e>Not applicable</e></row>
<row rc="26" layout="detail.1.1"><e> PAPER</e><e>Paper</e><e>Purchased</e><e></e><e>PUR</e><e>?-璐鐋╂缁-</e><e>Not applicable</e></row>
<row rc="27" layout="detail.1.1"><e> PC</e><e>绲?</e><e>Manufactured</e><e></e><e>MAN</e><e>?堕+犵|╂缁-</e><e>Not applicable</e></row>
<row rc="28" layout="detail.1.1"><e> PC2</e><e>姘绲?</e><e>Manufactured</e><e></e><e>MAN</e><e>?堕+犵|╂缁-</e><e>Not applicable</e></row>
<row rc="29" layout="detail.1.1"><e> SERI</e><e>搴宸鐋╂</e><e>Manufactured</e><e></e><e>MAN</e><e>?堕+犵|╂缁-</e><e>Not applicable</e></row>
<row rc="30" layout="detail.1.1"><e> SERVICE</e><e>驽+℃?/e><e>Service</e><e></e><e>SER</e><e>驽+$|╂缁-</e><e>Not applicable</e></row>
<row rc="31" layout="detail.1.1"><e> SPC</e><e>Special PC</e><e>Purchased</e><e></e><e>PUR</e><e>?-璐鐋╂缁-</e><e>Not applicable</e></row>
<row rc="32" layout="detail.1.1"><e> SUB-EMB-1</e><e>?|鍇鐋╂</e><e>Subcontracting</e><e></e><e>SUB</e><e>?|鍇鐋╂缁-</e><e>Not applicable</e></row>
<row rc="33" layout="detail.1.1"><e> WOOD-INP</e><e>杩?妯?/e><e>Purchased</e><e></e><e>PUR</e><e>?-璐鐋╂缁-</e><e>Not applicable</e></row>
<row rc="34" layout="detail.1.1"><e> WOORD-LOCAL</e><e>鍫敡妯?/e><e>Purchased</e><e></e><e>PUR</e><e>?-璐鐋╂缁-</e><e>Not applicable</e></row>
<row rc="35" layout="detail.1.1"><e>PRJ000001KEYBOARD</e><e>楫?e><e>Purchased</e><e></e><e>PUR</e><e>?-璐鐋╂缁-</e><e>Not applicable</e></row>
<row rc="36" layout="detail.1.1"><e>PRJ000001PC</e><e>瀹?剁佃-</e><e>Manufactured</e><e></e><e>MAN</e><e>?堕+犵|╂缁-</e><e>Not applicable</e></row>
<row rc="37" layout="detail.1.1"><e>PRJ000002KEYBOARD</e><e>楫?e><e>Purchased</e><e></e><e>PUR</e><e>?-璐鐋╂缁-</e><e>Not applicable</e></row>
<row rc="38" layout="detail.1.1"><e>PRJ000002PC</e><e>瀹?剁佃-</e><e>Manufactured</e><e></e><e>MAN</e><e>?堕+犵|╂缁-</e><e>Not applicable</e></row>
<pagebreak/>
</body>
</report>
--------------------编程问答-------------------- 编码的问题
不知道你从哪里读取到的
用 utf-8 gb2312试一下 --------------------编程问答-------------------- <?xml version='1.0' encoding='GB2312'?> --------------------编程问答-------------------- 把
<?xml version="1.0"?>
改成
<?xml version="1.0" encoding="GB2312"?>
试试 --------------------编程问答-------------------- <?xml version="1.0" encoding="GB2312"?>
--------------------编程问答-------------------- 这段内容是你在读取xml时程序debug过程中通过跟踪变量值拷贝下来的还是直接打开xml文件拷贝下来的?
如果是前者,可以像楼上那样添加encoding="gb2312"或者encoding="UTF8"分别试试
如果是后者,可能是xml文件有问题~比方可能是生成的时候不规范 --------------------编程问答-------------------- <?xml version="1.0"?>
=>
<?xml version="1.0" encoding="gb2312"?> --------------------编程问答-------------------- 用vs编辑xml文件,保存时选UTF-8格式 --------------------编程问答-------------------- <?xml version='1.0' encoding='GB2312'?>
你没有指定编码标准 --------------------编程问答-------------------- 改成
<?xml version='1.0' encoding='GB2312'?>
就不会乱码了 --------------------编程问答-------------------- LZ解决了没有,我也是这个问题 --------------------编程问答--------------------
XmlDocument xmlDoc = new XmlDocument();
XmlDeclaration xmldecl = xmlDoc.CreateXmlDeclaration("1.0", "gb2312", null);
xmlDoc.AppendChild(xmldecl);
这是保存的时候指定格式,就没事了 --------------------编程问答-------------------- 设置下字体..........
--------------------编程问答-------------------- 搂主需要指定文件编码,改成下面:
<?xml version='1.0' encoding= 'gbk'?>
然后重新打开,就正常了。
注意:最好用记事本打开修改保存。
补充:.NET技术 , C#