13 years ago
XmlHolder-XPATH problem when xml root element has xmlns
Hi,
I am trying to the get the node values for a XML string using the XML Holder.
below code is not working when xml string has namespace(ClinicalDocument xmlns=\"urn:hl7-org:v3\")
Below is the sample groovy code i am using.
XmlHolder holder = new XmlHolder("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><ClinicalDocument xmlns=\"urn:hl7-org:v3\"><title>plan of title</title></ClinicalDocument>")
holder.namespaces["xmlns"]="urn:hl7-org:v3"
def node = holder["//ClinicalDocument/title"]
def node1 = holder.getNodeValue("//ClinicalDocument/title");
log.info(node1);
log.info(">>>node = " + node)
Any help is appreciated.
Thanks
Ravi
I am trying to the get the node values for a XML string using the XML Holder.
below code is not working when xml string has namespace(ClinicalDocument xmlns=\"urn:hl7-org:v3\")
Below is the sample groovy code i am using.
XmlHolder holder = new XmlHolder("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><ClinicalDocument xmlns=\"urn:hl7-org:v3\"><title>plan of title</title></ClinicalDocument>")
holder.namespaces["xmlns"]="urn:hl7-org:v3"
def node = holder["//ClinicalDocument/title"]
def node1 = holder.getNodeValue("//ClinicalDocument/title");
log.info(node1);
log.info(">>>node = " + node)
Any help is appreciated.
Thanks
Ravi