Forum Discussion

fenwickr's avatar
fenwickr
Occasional Contributor
10 years ago

Updating Second Child Element

Below is the Code I am using to setup 2 child nodes Selection of Selections- I need to updated the second child node/Element with a New ID and order Number - I have tried to use XmlUtils.getChildElem...
  • fenwickr's avatar
    10 years ago

    Found the answer put in [] after the element and the number of the node/element you are after 

    So parentNode = reqHolder.getDomNode("//Selection") will become parentNode = reqHolder.getDomNode("//Selection[1]") to update the first element/Node and ("//Selection[2]") for the second

     

    parentNode = reqHolder.getDomNode("//Selection[1]")
    parentNode.setAttribute("id", '${#Project#WRunner1}')
    parentNode.setAttribute("order", "1")
    reqHolder.updateProperty()

     

    parentNode = reqHolder.getDomNode("//Selection[2]")
    parentNode.setAttribute("id", '${#Project#WRunner2}')
    parentNode.setAttribute("order", "2")
    reqHolder.updateProperty()