如何在java中动态更改xml?

时间:2022-04-21 18:59:40

I have written xml file which contains html tags as element like

我编写了包含html标签的xml文件作为元素

<component>
<input type="button">
<button id="1">
<class="mytest1">
</component>

now i want to first write a html file with these tags like

现在我想首先用这些标签写一个html文件

<input type="button" class="mytest" id="1">

.and when i change button to text,in xml also it shud be change button to text.

。当我将按钮更改为文本时,在xml中也可以将按钮更改为文本。

2 个解决方案

#1


0  

Yes, use the Observer pattern.

是的,使用Observer模式。

Every time your HTML is changed, a method should be called which then processes the XML.

每次更改HTML时,都应调用一个方法,然后处理XML。

#2


1  

You could create a watch service, as shown here. The service will notify you of any changes and you can take the appropriate action.

您可以创建一个监视服务,如下所示。该服务将通知您任何更改,您可以采取适当的措施。

#1


0  

Yes, use the Observer pattern.

是的,使用Observer模式。

Every time your HTML is changed, a method should be called which then processes the XML.

每次更改HTML时,都应调用一个方法,然后处理XML。

#2


1  

You could create a watch service, as shown here. The service will notify you of any changes and you can take the appropriate action.

您可以创建一个监视服务,如下所示。该服务将通知您任何更改,您可以采取适当的措施。