IF FindNode2(XMLDoc, 'IMTimeStampSearchResult', Node) THEN BEGIN TextoCDATA := Node.InnerText; XMLDoc.LoadXml(TextoCDATA); END;
Name DataType Subtype Length XMLDoc DotNet System.Xml.XmlDocument.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' Node DotNet System.Xml.XmlNode.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' TextoCDATA Text
FindNode2(XMLRootNode : DotNet "System.Xml.XmlNode";NodeName : Text;VAR FoundXMLNode : DotNet "System.Xml.XmlNode") : Boolean FoundXMLNode := XMLRootNode.SelectSingleNode(STRSUBSTNO('//*[local-name()="%1"]', NodeName)); IF ISNULL(FoundXMLNode) THEN EXIT(FALSE) ELSE EXIT(TRUE);
Answers
You don't need any special function to deal with CDATA, just select the node with the CDATA and assign its InnerText value to a Text variable.
Regards.
It is many nodes within the CDATA tag. The response could include a set of elements for dozens of entities (Customers or Vendors) per our Restricted Party Screening process I've been tasked with building. The CDATA tag seems to make it so NAV2013 can't see any of the elements within the CDATA tag (the open and close tags are seen as other characters). NAV can't seem to find the nodes I actually need to read that are within the CDATA section.
Ussually inside the CDTA there is another XML structure, so you need to load previous Text variable into a new XML and parse this one.
If you could post an example of the response I could be more specific.
Regards
Here is the general structure of the reply. The SHresult can be one or many.
Wiht this example you must to read the <IMTimeStampSearchRedsult> tag and assign the result to a new Xml document and parse this new one.
The XMLDoc variable must be the response XML and with the code below
in that variable you get the Xml inside the CDATA part.
These are the variables:
The FindNode2 function is this one:
Regards
One more very dumb question from me - when Finding the node in FindNode2, is the base string being used in the string substitution supposed to be specific to my file, or directly as shown in your example? When I run the code as shown in your example, it never finds the node IMTimeStampSearchResult (always exits FALSE).
It's de name of the tag with the CDATA value, in your example is IMTimeStampSearchResult:
REgards
Thanks, I understand that part, but not the syntax of the SelectSingleNode string parameter.
In your code example, you are passing the nodename into //*[local-name()="%1"]. This always results in a null node for me and the function returns False.
I also tried other hard-coded syntax iterations (just to test) like:
FoundXMLNode := XMLRootNode.SelectSingleNode('//*["IMTimeStampSearchResult"]');
-or-
FoundXMLNode := XMLRootNode.SelectSingleNode('//"IMTimeStampSearchResult"');
-or-
FoundXMLNode := XMLRootNode.SelectSingleNode('//IMTimeStampSearchResult');
-or-
FoundXMLNode := XMLRootNode.SelectSingleNode('IMTimeStampSearchResult');
-or-
FoundXMLNode := XMLRootNode.SelectSingleNode('//Envelope/Body/IMTimeStampSearchResponse/IMTimeStampSearchResult');
and all of these fail as well.
Is the namespace the problem? Do I need to remove that first, then try to get at the CDATA?
Yes the problem with your hard-coded calls are the namespaces.
But the function FindNode2 works fine, did you created the function ?
Could you post the complete code that are using ?
Regards.
Thanks to your wise request to see my code, when I went to copy/paste it here, I noticed an oversight in one missing line in my logic that was responsible for all of my problems. Thank you!! I am now seeing the contents of the CDATA tags. My next step will be to figure out how to handle that data, but your assistance was truly invaluable. Thank you!