I wish to have a groovy function which can take 2 or more parameters something like input, find_tag.
I wrote something like below to test(not function), but it does not give me D_1164898448. Please help me with it.
def temp="""<Portals objVersion=\"1.1.19\">
<vector xsi:type=\"domainservice:Portals\" objVersion=\"1.1.19\">
<domainName>D_1164898448</domainName>
<address xsi:type=\"metadata:NodeRef\" objVersion=\"1.1.19\">
<host>Komodo</host>
<port>18442</port>
</address>
</vector>
</Portals>"""
def fInput="domainName"
def records = new XmlParser().parseText(temp)
def t=records.findAll{ it.fInput}.text()
println t
Update
for attribute i am doin something like below
println "id = ${records.attribute("id")}"
but like wise how to do it for nodes?
println "host = ${records.vector.address.host.text()}"
If you don’t know the exact path to the XML tag you’re searching for, you can do something like this to get the content of all tags with the given name:
To access attributes from a given XML node you can also use the
@notation, e.g.