在 xml 中存储 url 的正确方法? [英] Proper way to store an url in xml?

查看:48
本文介绍了在 xml 中存储 url 的正确方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将数据存储在 xml 文件中,在其中一个节点中,我必须存储一个包含特殊字符的 url,如 &我用 &amp 而不是 &并且xml没有显示错误但是当我做SAX解析节点内返回的字符串值是&之后的字符串,

I am storing data in xml file, In one of the node I have to store an url which consists of special character like & I used &amp instead of & and xml shows no error but when I did SAX parsing String value returned within the node is the string which is after &,

我猜我存储 url 的方式不正确.

I am guessing the way I am storing the url is not proper.

在 xml 中存储 url 的正确方法是什么.

What is right way of storing an url in xml.

目前我存储为,

<param>http://www.example.com?param1=abc&amp;v=1</param>

XML 没有错误,但 SAX 解析器不会返回整个 url.

XML has no errors, but SAX parser won't return the whole url.

我在网址中的 &amp 后面有分号,我第一次错过了.

I have semicolon after &amp in the url, I missed it the first time.

解决方案:这不是 XML 的问题,而是我在 XMLHandler 中处理 XML 的方式,
我使用的是 new String(ch,start,length);
现在改为 stringBuilder();

Solution: It was not the problem with XML , but the way I handled XML in XMLHandler,
I was using new String(ch,start,length);
Now changed to stringBuilder();

推荐答案

你的 XML 是正确的(现在你已经添加了分号),所以你对 SAX API 的使用肯定是错误的.

Your XML is correct (now that you have added the semi-colon), so your use of the SAX API must be wrong.

也许看下面的答案:Sax 解析和编码

这篇关于在 xml 中存储 url 的正确方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆