简体   繁体   English

Java中的XML编辑器(jsp,sevlet)

[英]XML Editor in java(jsp,sevlet)

I am developing xml editor using jsp and servlet. 我正在使用jsp和servlet开发xml编辑器。 In this case i am using DOM parser. 在这种情况下,我正在使用DOM解析器。

I have one problem in XML editor , How to edit the following xml file without losing elements. 我在XML编辑器中遇到一个问题,即如何在不丢失元素的情况下编辑以下xml文件。 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. 我尝试使用jsp,servlet使用dtd编辑上述xml文件。 but while i read the textvalue from xml, it return only first,second,third.How to read the 'This is' and 'line '. 但是当我从xml读取textvalue时,它仅返回第一,第二,第三。如何读取“ This is”和“ line”。 Then how to store back to the xml file using xpath. 然后如何使用xpath存储回xml文件。

thank in advance. 预先感谢。

The <b> tag inside the <para> tag is another element, not a formatting tag (in XML). <para> <b>标记内的<b>标记是另一个元素,而不是格式标记(在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. 就像@JRL所说的那样, <b>标记被认为是格式正确的XML,因此,由DOM处理器拆分。

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. 我认为您无法读取其他文本元素,因为您仅在XML节点不再有XML节点时才读取文本,在这里不是您的情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM