baanware
21st February 2011, 17:06
Hi,

Using the standard XML parser I have been trying to read a multi-line field (which in the XML file contains line feeds: x'0D + x'0A).

I have tried to read the node using xmlgetdataelement as well as xmlgetdata but both functions removes all CR+LF's and presents the multi-line text as one (very long) field.

I tried to save the XML-file in UNIX format - the result was the same :-(

Can anybody tell me: How do I read such a multi-line field?

When I debug and display of the node (using "Show XML tree"), the individual lines are perfectly displayed. (?)

Thanks!

chijoe
25th November 2011, 11:18
Hi,

I just wanted to ask if you solved this problem because I have actually the same problem/situation and can find any solution. Would be great to hear from you!


Thanks

Sven

pconde
28th November 2011, 08:36
Hello,

i think that this could be done via the parameter whitespacehandling in the xmlread instuction:
long xmlRead(long fp, ref string error, [ long whitespacehandling ] )

whitespacehandling = xmlPreserveWhiteSpace. Look also in the help of xmlRead for more information.

Regards
Philippe

baanware
28th November 2011, 11:04
Hi All,

Yes I did get around the problem, but unfortunately not the most elegant way.

First I discovered that if the multiline text was surrounded by a "[CDATA[" tag it is treated as "Unparsed Character Data". The XML element would in other words have the following structure:
<nodename>"[CDATA[...multi-line text...]]</nodename>

Having done so the file was at least parsed without errors, but unfortunately the line feeds in the text were turned into spaces, and I needed well defined line breaks in the texts.

Therefore I decided to change all the line feeds into a dummy character sequence: "$$".

Having parsed the file and read the node, I now run the contents through a tiny procedure, which converts "$$" into a line feed.

Not elegant :-( ...but it works

chijoe
29th November 2011, 09:26
Hi,

thanks for the answers. Unfortunately my problem is the same but not exactly. Because I don't have a xml file which I read and load into the memory. I'm getting SOAP Responses directly into Baan via the Baan SOAP Client. So the Response is a XML Structure which goes directly into the memory.

SO I proberly don't have any other choice than contact the Baan Support!

Thanks

Sven

baanware
29th November 2011, 10:47
In case you have it in memory it should be even more simple. You just have to search the input string for CRLF and exchange the characters with your line "feed dummy characters" ($$ in my example). Afterwards the input string is ready for the LN XML parser

But if you could manage to make Infor Support fix the problem in a general way, it would be usefull to all of us - and a far better long term solution.

Best regards
Sören L

chijoe
30th November 2011, 09:07
Hi,

I've already tried that.But when I write the multiline content into a string Variable all CRLF are already cutted out. But all these function with write the content of a Node to a String do that. Or do you might know some function which I don't know? :-)

----------
string t.str(1) mb based
alloc.mem(t.str, 500000)
long t.file
long i
long ascii
string t.s(1)

t.xml.node = xmlFindFirst("Response", i.xml.response)
| t.str = xmlData$(t.xml.node)
| xmlAllocPrettyString(t.str, t.xml.node)
xmlWritePrettyToString(t.str, t.xml.node)



for i=1 to 5000
t.s = t.str(i;1)
ascii = asc(t.str(i;1))
endfor
----------


Thanks Sven