English 中文(简体)
Parse Ampersand in XML with Java s DOM XML AP
原标题:Parse Ampersand in XML with Java s DOM XML API
  • 时间:2011-10-12 02:30:19
  •  标签:
  • java
  • xml
  • dom

我试图将XML文件与Java DOM AP(而不是SAX)混为一谈。 每当教区遇到安放人(和)时,就错了。 我猜测,这已经减半,有1)es,2) en,3)使用不同的ser子。

I am reading an XML document that I dont have any control over, so I cannot precisely identify where the ampersand appears in the document every time I read it.

我所看到的类似问题表明,在将“XML”同起来时,将实体类型替换为一类,但我不敢肯定我如何能够这样做,因为当我碰到“XML”安插手时,它甚至会 par。

任何帮助都将受到赞赏。

问题回答

如前所述,XML已作正式信息(oo!):& in XML(除了象征性地引入一个特性实体[?]外)必须编码为&

一些解决办法(基本上如后文所述):

  1. Fix the XML (at source, or in hack-it-up phase), or;
  2. Parse it with the "appropriate" tool (e.g. a "forgiving" HTML parser)

关于“hack-it-up”办法,审议一个单独的投入流:见Working with Filtertranss ->,即作为过滤器执行:prior <>/em>投到实际的DOM parser:每当有<代码>&(并非实体部分)碰到时,插入“通过密码插入>和<>。 当然,如果XML的源头拿到基本编码正确......

幸福 co。

“我阅读了I dont掌握的XML文件”。

页: 1 你之所以出现错误,是因为XML教区必须给你一个错误,因为你读的是XML。

The XML culture is that responsibility for producing well-formed XML rests with the sender. You need to change whatever produces this data to do it properly. Otherwise, you might as well forget XML and its benefits, and move back to the chaotic world of privately-agreed protocols and custom parsers.





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签