您的位置:程序门 -> .net技术 -> c#



请教 xml传参数中文乱码问题 急!


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


请教 xml传参数中文乱码问题 急!
发表于:2007-01-09 09:30:12 楼主
左边是treeview目录树,调用的是xml数据,链接url存于xml文件中,但链接页接收目录树页传的中文参数是乱码?请问该怎么解决??谢谢!!!困或一天了
目录树里的链接类似:mainframe.aspx?id=1&class=计算机     mainframe.aspx里接收到的class就是乱码
发表于:2007-01-09 09:38:021楼 得分:0
到底是url还是xml?
如果是xml的话   装个ie6.0试试
发表于:2007-01-09 09:41:252楼 得分:0
这是xml文件内容:
...
<treenode   text= "小学一年级 ">
                <item   text= "语文上册 "   value= "mainframe.aspx?bigclass_id=25&amp;smallclass_id=150&amp;lastclass_id=624&amp;roottype=人教版同步辅导 "   />
                <item   text= "语文下册 "   value= "mainframe.aspx?bigclass_id=25&amp;smallclass_id=150&amp;lastclass_id=625&amp;roottype=人教版同步辅导 "   />
                <item   text= "数学上册 "   value= "mainframe.aspx?bigclass_id=25&amp;smallclass_id=150&amp;lastclass_id=626&amp;roottype=人教版同步辅导 "   />
                <item   text= "数学下册 "   value= "mainframe.aspx?bigclass_id=25&amp;smallclass_id=150&amp;lastclass_id=627&amp;roottype=人教版同步辅导 "   />
            </treenode>

链接取的是   value
发表于:2007-01-09 09:41:423楼 得分:0
你   xml   编码方式是什么啊?     utf-8   还是   gb2132?
改成   utf-8   试下,   还有你那   web.config   要一致
发表于:2007-01-09 09:46:034楼 得分:0
xml是utf-8,改成gb2312会抱错,web.config里gb2312和utf-8都试了,还是不行
发表于:2007-01-09 09:55:355楼 得分:0
自己顶,请高手帮帮忙,谢谢!!
发表于:2007-01-09 10:21:036楼 得分:0
用这个urlencode编码和urldecode看看,同时xml换成gbk格式

在你xml文件可能出现特殊符号的地方用   : <![cdata[]>

<autn:title> <![cdata[ "+dt.rows[i][2].tostring()+ "]]> </autn:title>
可以参考我这个看看,当时我也是出现了乱码后来解决了! //************输出xml格式*************//

stringbuilder   strbuilder   =   new   stringbuilder();
strbuilder.append( " <?xml   version= ")
.append( "\ "1.0 ")
.append( "\ " ")
.append( "   encoding= ")
.append( "\ "gbk ")
.append( "\ "   ?> ")
.append( " <autnresponse> ")
.append( " <responsedata   xmlns:autn= ")
.append( "\ " ")
.append( "http://www.addl.com.cn/ ")
// .append( "http://www.addl.com.cn/ ")
.append( "\ "> ")
.append( " <autn:numhits> "+numhits.tostring()+ " </autn:numhits> ")
.append( " <autn:totalhits> "+totalhits.tostring()+ " </autn:totalhits> ");
//开始返回多条记录//
for(int   i=0;i <dt.rows.count;i++)
{
strbuilder.append( " <autn:hit> ")
.append( " <autn:reference> http://localhost/eng/engdetails.aspx?cateid= "+dt.rows[i][1].tostring()+ "&amp;engid= "+dt.rows[i][0].tostring()+ " </autn:reference> ")
.append( " <autn:num> "+dt.rows[i][0].tostring()+ " </autn:num> ")
.append( " <autn:database> 工程设计作品库 </autn:database> ")
//.append( " <autn:title> "+dt.rows[i][2].tostring()+ " </autn:title> ")
.append( " <autn:title> <![cdata[ "+dt.rows[i][2].tostring()+ "]]> </autn:title> ")
.append( " <autn:author> </autn:author> ")  
.append( " <autn:format> aspx </autn:format> ")
.append( " <autn:createdate> </autn:createdate> ")
.append( " </autn:hit> ");
}
//结束返回多条记录//
strbuilder.append( " </responsedata> ")
            .append( " </autnresponse> ");


response.write(strbuilder.tostring());
response.end();


快速检索

最新资讯
热门点击