开发者

XML Editor in java(jsp,sevlet)

I am developing xml editor using jsp and servlet. In this case i am using DOM parser.

I have one problem in XML editor , How to edit the following xml file without losing elements. eg:

<book id="b1">
<bookbegin id="bb1">
<para id="p1">This is<b>first</b>line</para>
<para id="p2">This is<b>second</b>line</para>
<para id="p3">This is<b>third</b>line</para>
</bookbegin>
</book>
开发者_运维知识库

I try to edit the above xml file using dtd using jsp,servlet. but while i read the textvalue from xml, it return only first,second,third.How to read the 'This is' and 'line '. Then how to store back to the xml file using xpath.

thank in advance.


The <b> tag inside the <para> tag is another element, not a formatting tag (in XML). Therefore, you need to traverse down to it.


Like @JRL says, the <b> tags are cosnidered as well-formed XML and, as a consequence, splitted by your DOM processor.

I think youf ail to read other text elements because you only read text when an XML node has no more XML node, which is not your case here.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜