开发者

Parsing section from XML

I have a XML document. From the whole document I want to parse a particular section using Java

   <sec sec-type="methods">
    .....
   </sec>

There are开发者_运维百科 child sec in the "methods". How do I parse it? I need to get the titles and the text content from each of the nodes.

Thanks,


First, you need to parse the entire document, not just a section of the document. Trying to pull a section out of an XML document without parsing (at least) the stuff preceding it is liable to be fragile ... especially if there are changes in the way that the XML is created.

Second, you need to read up on the technologies for parsing XML and decide which one best suits your use-case. Here are some resources:

  • The Sun XML Tutorial stream.
  • Wikipedia material on XML processing and JAXP.

There are various other approaches, but I don't want to confuse you with a million choices.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜