XML文件和&字符作为数据 [英] XML file and & character as data

查看:73
本文介绍了XML文件和&字符作为数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,


我有一个使用Iso 8859-1编码的XML文件。

每当我尝试放入&字符作为标记的值

喜欢< tag>这是&字符< /标签>在我的申请中显示例外
。我在.NET平台上使用XMLDocument阅读器。


人们如何编码&字符作为一个普通的数据字符?

我不是指任何平台相关的解决方案只是XML的观点。


干杯!

Hello,

I have a XML file using Iso 8859-1 encoding.
Every time when I try to put & character as Tag''s value
like <tag>This is & character</tag> Exception is shown
in my application. I use XMLDocument reader in .NET platform.

How should people code & character as an ordinary data character?
I don''t mean any platform dependent solution just XML''s point of view.

Cheers!

推荐答案

在文章< e2 ********** @ nyytiset.pp.htv.fi>中,BenI< ;是***** @ yahoo.com>写道:
In article <e2**********@nyytiset.pp.htv.fi>, BenI <be*****@yahoo.com> wrote:
我有一个使用Iso 8859-1编码的XML文件。


这与编码无关。

每当我尝试放置&字符作为Tag'的值
喜欢< tag>这是&字符< /标签>在我的申请中显示了例外情况。
I have a XML file using Iso 8859-1 encoding.
It''s nothing to do with the encoding.
Every time when I try to put & character as Tag''s value
like <tag>This is & character</tag> Exception is shown
in my application.




&在XML中用于实体引用。要获得&符号

字符,您必须输入& amp;,例如:


< tag>这是&放大器;字符< / tag>


- Richard



& is used in XML for entity references. To get the ampersand
character, you have to type "&amp;", for example:

<tag>This is &amp; character</tag>

-- Richard


BenI写道:
你好,

我有一个使用Iso 8859-1编码的XML文件。
每当我尝试放入&字符作为Tag'的值
喜欢< tag>这是&字符< /标签>在我的申请中显示了例外情况。我在.NET平台上使用XMLDocument阅读器。

人们如何编码和字符作为一个普通的数据字符?
我不是指任何平台相关的解决方案只是XML的观点。

干杯!
Hello,

I have a XML file using Iso 8859-1 encoding.
Every time when I try to put & character as Tag''s value
like <tag>This is & character</tag> Exception is shown
in my application. I use XMLDocument reader in .NET platform.

How should people code & character as an ordinary data character?
I don''t mean any platform dependent solution just XML''s point of view.

Cheers!



使用转义码& amp;


Steve


Use the escape code &amp;

Steve


Richard Tobin写道:
Richard Tobin wrote:
&在XML中用于实体引用。要获得&符号和/或字符,您必须键入& amp;,例如:
& is used in XML for entity references. To get the ampersand
character, you have to type "&amp;", for example:




或使用数字字符转义符,&或&#x26;。


你还需要为<和>字符(& lt;和& gt;)。


请注意,如果您通过XML API(如SAX)操作数据

或DOM,角色与其XML转义版本之间的转换,或

反之亦然,将为您自动处理。


-

Joe Kesselman /小心病人的愤怒。 - John Dryden



Or use a numeric character escape, & or &#x26;.

You''ll also need to do this for the < and > characters (&lt; and &gt;).

Note that if you''re manipulating the data through an XML API such as SAX
or DOM, conversion between the character and its XML escaped version, or
vice versa, will be handled automagically for you.

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden


这篇关于XML文件和&amp;字符作为数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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