I have a requirement to query an xml which of the below format
<root xmlns:xsi=<> xmlns:xsd=<> xmlns:
the requirement is to fetch the value of key1. The way I followed is, I got the rootLocalName of xml and prepared an XPath to query the node like this
but, the query gave me null results.
Can some one help me on this?
do you have the DocType representation available in your IS (i.e. created from a XSD)?
Then you can just right click on the field in the pipelina and select “copy”.
This can be pasted into the query field.
Firstly thanks for your reply!
I didn’t have DocType for this. The original requirement was with prefix and now, user come up with additional requirement that the service should serve the xmls without rootPrefix.
I have seen many posts saying that it is difficult to query a node with defaultNamespace. But, I have to get it done without disturbing the input xml root tag.
Please suggest me way to do it.
You mean to say that Root Tag of the XML received can change during run time?
Whether this path parent1/key1 is unchanged?[/color]
can you provide a screenshot of your flow implementation?
You should try to get the XSD for this XML message from the partner as this will ease development a lot.
sorry, I can’t provide screenshot of the XML.
No, my requirement is to write an xPath to query an XML Node which has default namespace.
The rootLocalName (root tag) and the child tags will remain same for a given input.
then your xpath should be “/root/parent1/key1”.
That Xpath is not working, it is fetching me null values. I have tried this option as well
I did some research meanwhile.
Hopefully your XML is welformed (only one node with name root after the <?xml>-Tag).
Here are some options to try:
Did you try to specify the namespace in the nsDecls-Parameter?
Which QueryLanguage are you using?
WQL or XQL?
Usually the XQL should be preferred over WQL.
If this does not help, please provide a screenshot of pub.xml:queryXMLNode step.
XQL is preferred way and yes please upload the screenshot clearly the settings you are inputting to queryXMLNode service.
Attach the test XML also if possible.
Thanks for your suggestion and reply.
I have got the query executed using the below format to fetch the values from XML.
It works for both scenarios, with and without prefix.
Glad to hear you were able to resolve it with the syntax above
I agree with RMG.
Luckily you have figured out the correct query.
As there was never a sample xml structure with namespaceprefix present inside the tags we might have been looking in the wrong direction sometimes.
As there different types of presentations of xml messages regarding the presence or absence of namespace prefixes this can be confusing when not knowing all occuring variants.
- All elements have prefixes
- No element does have a prefix
- Only the root element does have a prefix
This depends on how xsd are composed/cascaded with namespaces defined and if they define elementFormQualified as true or false.
In my project I have observed all 3 types of messages for different interfaces causing more or less trouble when importing them into the IS as well as constructing test and reference data for testing them on either 7.1 or 9.5.