vendredi 15 juillet 2016

edit attribute in xml java

I want to know how to edit an attribute inside of a node which is inside of another node. This would be an example of my xml:

<name>Rule_1</name>
<synonymn name="user" class="test.user" />

  <rule name="adult">
    <if leftTerm="user.getAge" op="&gt;" rightTerm="18" />
    <then method="user.mostrarMensaje" arg1="true" />
  </rule>

  <rule name="underAge">
    <if leftTerm="user.getAge" op="&lt;" rightTerm="18" />
    <then method="user.showMessage" arg1="false" />
  </rule>

I want to change the attribute rightTerm of each rule to 20 but I can't access it and I'm getting NullReferenceException.

I'm using Java DOM parser.

Aucun commentaire:

Enregistrer un commentaire