I am trying to retrieve the value of Client Element which is a row in array returned as XML SOAP. I use the following call, but don't know why I dont get any result (and no any error too).
Can anyone help please? |
I am trying to retrieve the value of Client Element which is a row in array returned as XML SOAP. I use the following call, but don't know why I dont get any result (and no any error too).
Can anyone help please? |
Once you sign in you will be able to subscribe for any updates here
By RSS:Markdown Basics
Question tags:
question asked: 15 Jul '20, 11:18
question was seen: 839 times
last updated: 24 Jul '20, 10:06
I'm not sure you can query the contents of a CDATA section via XPath directly - you might first need to extract it as a separate XML document here...
Generally, when parsing "new XML documents" with OpenXML, I have learnt to use the meta properties within the WITH clause to make sure I'm querying the right nodes (and do not stumble over missing namespaces and the like, as I have done all too often)...
do you mean that I should extract the content of CDATA as text and then extract each element separately? i.e. should I need to use OPENXML twice?
The problem is that I can't even extract the content of CDATA!
By replacing the last line in the code above for example with:
'//*:Body/*:GetDetailResponse/*:MyDataset') with (CusotmerID varchar (100) 'text()');
My main problem is not with CDATA, as I can replace <![CDATA[<?xml version="1.0"?> with '' and ]]> with ''.
I am not sure where exactly to use *: and where not to use in the last line of the code
You can always use '*:' before any node/attribute name to allow any namespace - unless the XML actually does use identical names in different name spaces so you have to distinguish the name spaces.
But note that names are case-sensitive, while your sample does treat them as case-insensitive.
Ok, clear. One more question, what if some element has an embedded attribute in it, like:
Do I need also to add *: too or *: is really only for the namespace preceeding the element name (something like ns1: or ns2: or whatsever).
As stated, I'd really recommend to use the metaproperties to try to list all nodes and attributes with their values - that's the easiest way IMHO to find out how to adapt the desired XPath queries.
That being said, your last question is a general XML question better asked in general XML forums...
I could get the correct value of client after correcting the following points:
My question is, how can I deactivate the effect of CDATA, so that I get the Data within CDATA as Markup and not as literal text:
In other words, I want to get:
instead of:
& lt ; client & gt ; 200403 & lt ;/client & gt ;
Actually I could also solve this problem by:
replace(mytext, '& lt ;' , '<');
but this takes too long time, and I wanted to know whether there is some ready function for this.
See the html_decode() and html_encode() builtin functions, the first should do exactly what you are trying to.
Instead of using replace to "flatten" the CDATA contents, you might take the according node's contents and handle it as a separate XML document (which it is, obviously).
Thank you very much, yes html_decode() does what I want.
Yes, this is what I want, but I can't bring these together.
Is there any simple example showing how to deal with CDATA?
There are XPath functions to do so according to the internets, but I guess those are not supported by SQL Anywhere's subset of XPath functions.