English 中文(简体)
如何在不使用主食的情况下读xml数据?
原标题:How to read xml data without using parser(dom,sax)?
  • 时间:2010-11-10 10:30:21
  •  标签:
  • java
  • xml

I am new to xml. I have to read all the elements of xml file without using a parser. please help me.I can make use of string functions with regular expressions.but i am not familiar with them. so please help me to give me a code to read atleast 2 xml elements one is root and other one is child.

问题回答

您可使用标准<代码>java.io的包裹,特别是java.io.FileReaderjava.io.BufferedReader

This will enable you to read the xml file and get the content as standard java.lang.String.

一旦您具备能力,你就能够利用定期表达来过滤其xml型数据。

www.un.org/Depts/DGACM/index_spanish.htm 这肯定不是书写Xml parser的最有效方式,并且严格涵盖标准Xml parser提供的所有教区能力。

假设你的XML是有效的、知情的,并且不能把同一名称的标签nes开,你可以使用以下reg子与整个标签相匹配,例如指名的标签<儿童:

<s*child(?:(?!<s*/s*child).)+<s*/s*childs*>

知道在 Java的路里利用这一点,你不得不把所有斜坡翻一番;你想利用<代码”汇编该浮游。 模式.DOTALL备选方案。

解释(为了清晰起见删除的选择性白色空间):

<child       # match opening tag
(?:          # then match...
 (?!</child) # as long as it s not at the start of the closing tag:
 .           # any character
)+           # as many times as possible
</child>     # then match the closing tag




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

热门标签