English 中文(简体)
如何删除<?xml ?> 处理指令
原标题:How remove the <?xml ...?> processing instruction
  • 时间:2011-11-22 10:01:30
  •  标签:
  • java
  • xml

我需要将处理指令从OMD中删除。 我装上了几个档案,合并并节省了这些档案。 但问题是,结果就好像:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<frag>
    Jó foxim és don Quijote húszwattos lámpánál ülve egy pár bűvös cipőt készít.
</frag>
<?xml version="1.0" encoding="iso-8859-2" standalone="no"?>
<frag>
    Jó foxim és don Quijote húszwattos lámpánál ülve egy pár bűvös cipőt készít.
</frag>
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<frag>
    Jó foxim és don Quijote húszwattos lámpánál ülve egy pár bűvös cipőt készít.
</frag>

I haven t found the way the <?xml ...?> process instruction can be either removed from DOM or ignored when saving the resulting DOM. I m using Java 6 and the default parser.

最佳回答

没有取消程序指示的方法。

Your merge process is broken. I ll bet you re reading the fragment files and simply concatenating the strings together to create this example.

这样做的正确办法是将每一块碎块混为一谈,并添加内容,以便最终进入原产地。

即便你删除了处理指示,你所公布的内容也是无效的XML。 我看不到任何根基,你必须有一个,只有一个。

问题回答

You can remove processing instructions by using the SAX API - a XMLStreamReader for example. You can create a FilteredReader using the XMLInputFactory and a StreamFilter.

有一个固定的<代码>XMLStreamConstants.PROCESSING_INSTRUCTION,可帮助过滤器识别处理指示并收回。

类似情况当然也是有可能的,安特遣部队也这样做。

无论技术可行性如何,这种合并确实会按照“ d”的建议打破。





相关问题
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 ...

热门标签