0
def xmlRecords = new XmlParser().parseText(peopleString)

  //  println xmlRecords.person.subject_datas
    println "123"
    def datas = xmlRecords.person.subject_datas
    def newNode = new Node(datas, 'subject_data')
    def newSubNode = new Node(newNode, "subject_field_id", ["type", "integer"], "123max offer")
    def newSubNode1 = new Node(newNode, "value", "1000")
    def newNode2 = new Node(datas,"subject_data")
    def newSubNode2 = new Node(newNode, "subject_field_id", ["type", "integer"], "123application Status")
    def newSubNode21 = new Node(newNode, "value", "APPLIED")

Hi All,

I am face to a problem when I am trying to update a xml response.

I am using parseText to convert xmlstring to node. And then use the constructer to create a Node obj. new Node(NodeList, Object(name))

I got confused by the name which should use Object. When I put String here I got Could not find matching constructor for: groovy.util.Node(groovy.util.NodeList, java.lang.String). Do I need to convert String to Object? ?_?

tim_yates
  • 167,322
  • 27
  • 342
  • 338
  • First take a look at Node class and its available constructors. You have not added any inputs and what actually you want to achieve. – Sandeep Poonia May 30 '16 at 05:49
  • Thank you for reply, I check the Node class. All the way to setup a name for a Node, the type of name is Object. Just wondering in this case how can we set up the name of a new Node? @SandeepPoonia. – Richard Mao May 31 '16 at 14:39
  • Could you please provide the sample input and what you are trying to achieve? – Sandeep Poonia May 31 '16 at 16:03
  • Updated. Got the issue. The issue is not from name. It is from Node/NodeList. What I got from 'new XmlParser().parseText(peopleString)' is NodeList. What I should do is get(0). This is the high level Node in the NodeList. Put Node in the new Node() is working – Richard Mao May 31 '16 at 17:19
  • peopleString is the very first input which is a xmlstring – Richard Mao Jun 01 '16 at 20:35

0 Answers0