Problem with < and > in XML file
Lamza
Member Posts: 8
I'm trying to parse an XML file in NAV which has < and > characters instead of < and > as element definition. I'm accessing the file through a web service. Problem is that I can't access those elements because they're interpreted as text and not as valid XML elements. Any ideas?
0
Comments
-
So does your explination means that
I xml consists of:<mainelement> <subelement> <inner>tekst tekst 1 > 0</inner> <inner>other tekst 20 < 30</inner> </subelement></mainelement>if I is the case then you ought to parse > and < with a function and return > or <.
II xml consists of<mainelement> <subelement> </subelement> <mainelement>
IF II is the case, then it's not a valid xml file, and no webservice will know what the elements are and what not.
< and > are meant to replace < and > in the file when they are not a part of the element because else an xml could be parsed incorrectly because < and > are inherent to an element. without these characters you have no xml-file.0 -
Yes, I know when these escape characters should be used and in my case they're not used properly, your case No. 2. But, this is a well known web service of a National Bank that provides current currency exchange rates and it's used by many parties so I'm worried that I'm the one who's doing something wrong, but don't know what?!0
-
Strange thing is that not all of the elements have escape characters attached. First couple of elements in the elements hierarchy are properly formated, but all of the rest aren't.0
-
All of the XML data I need is part of a SOAP Envelope. The elements regarding the SOAP envelope itself are properly formated, but the data I need is formated as string inside the last SOAP envelope element.0
-
So, to me it looks like you need to retrieve that string (in a Way that converts those entities back to characters) and then feed it to some XML processor (MSXML, XMLPort) as an XML document.Lamza wrote:All of the XML data I need is part of a SOAP Envelope. The elements regarding the SOAP envelope itself are properly formated, but the data I need is formated as string inside the last SOAP envelope element.0 -
Yes, but the problem is that the string in question is to big for the string variable of C/AL, so I'm trying to do something with the BigText variable.0
-
I have the same problem.
Content of the SOAP message is treated as plain text (> instead <) so my way around that problem was to use XmlDoc.text method to get the data.
XmlHTTP is defined as 'Microsoft XML, v6.0'.XMLHTTP
XmlDoc is defined as 'Microsoft XML, v6.0'.DOMDocument60
The code for getting data from SOAP is:XmlDoc.load(XmlHttp.responseBody); XmlDoc.loadXML('<Return>'+XmlDoc.text+'</Return>');I added dummy top level node <Return> just in case so that the XML inside SOAP message is correct (in case it hasn't top level node).
The problem is that the XmlDoc.text apparently doesn't handle long strings so I can't get the SOAP message data out of the XmlHTTP response.
BigText can't solve that problem because it's not the problem in storing text into a variable.
Anybody has any other idea we could try?Better to be critical then self-critical
0 -
This way

send request:xmlhttp.send(xmldoc); IF xmlhttp.status = 200 THEN BEGIN xmldoc := xmlhttp.responseXML; ProcessResponse(Rec,xmldoc); Response.CREATEINSTREAM(InStr); xmldoc.save(InStr); END ELSE ERROR(xmlhttp.statusText);
ProcessResponse(VAR Req, VAR xmldoc) // remove soap envelop node := xmldoc.selectSingleNode('Soap:Envelope/Soap:Body/YOURFUNCTIONCALL_Result/msgOut'); body := '<?xml version="1.0"?><resp/>'; CREATE(xmldoc2,TRUE,TRUE); xmldoc2.loadXML(body); node2 := xmldoc2.documentElement; node2.appendChild(node); xmldoc.loadXML(body); // unescape body := '<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.1">' + '<xsl:template match="resp">' + '<xsl:value-of select="." disable-output-escaping="yes"/>' + '</xsl:template>' + '</xsl:stylesheet>'; CREATE(XSLStyle,TRUE,TRUE); XSLStyle.loadXML(body); CREATE(XSLTemplate,TRUE,TRUE); XSLTemplate.stylesheet := XSLStyle; Processor := XSLTemplate.createProcessor; Processor.input := xmldoc2; Processor.output := xmldoc; IF NOT Processor.transform THEN ERROR(Text002);
vars:XSLStyle Automation 'Microsoft XML, v6.0'.FreeThreadedDOMDocument60 XSLTemplate Automation 'Microsoft XML, v6.0'.XSLTemplate60 Processor Automation 'Microsoft XML, v6.0'.IXSLProcessor
0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
