on 04-12-2006 1:47 PM
Hi,
I need to convert an XML containing special characters like & ' < to the XML codification (&,&apos, ..).
I'm having an XML like this :
<?xml version=''1.0'' encoding=''UTF-8''?>
<ROOT xmlns:sql=''urn:schemas-microsoft-com:xml-sql'' >
<sql:query>
select * from table where field = '1241&'
</sql:query>
</ROOT>
I tried to use the class cl_xml_document.
here is part of the code :
CALL METHOD lo_mxml->parse_string
EXPORTING
stream = xmlbody.
CALL METHOD lo_mxml->render_2_string
EXPORTING
PRETTY_PRINT = 'X'
IMPORTING
RETCODE = lv_Retcode
STREAM = lv_String
SIZE = lv_size.
CALL METHOD lo_mxml->display.
the result is :
<?xml version="1.0" encoding="iso-8859-1"?>
<ROOT xmlns:sql="urn:schemas-microsoft-com:xml-sql">
<sql:query>
SELECT * FROM table where field = '1
</sql:query>
</ROOT>
the rendering stops after having replaced the first special characters. any idea ? or another way for doing that ?
any help will be appreciated.
thanks,
regards,
Abdelaltif
Were you able to resolve this issue?
I am having similar situation in my XML files.
wrap the table containing the file into a stream
G_ISTREAM = G_STREAMFACTORY->CREATE_ISTREAM_ITABLE( TABLE =
T_XML_TABLE
SIZE = G_LEN ).
Creating a document
Before creating the XML DOM object, you have to create an empty doc
and a parser object. The document object will represent the DOM
object and the parser is needed to convert the XML stream into
a XML DOM object.
G_DOCUMENT = G_IXML->CREATE_DOCUMENT( ).
Create a Parser
G_PARSER = G_IXML->CREATE_PARSER( STREAM_FACTORY = G_STREAMFACTORY
istream = G_ISTREAM
DOCUMENT = G_DOCUMENT ).
Parse the stream
DATA: RTN TYPE I .
RTN = G_PARSER->PARSE( ) . (It stops/freezes here). I think it is to do with some special characters. Not sure how to resolve this.
You can contact me at cjrajesh@hotmail.com
Appreciate your help as this is pretty critical for our go-live.
Regards,
Rajesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
as you mentioned earlier you have to convert the & to &
concatenate
`<?xml version='1.0' encoding='UTF-8'?>`
`<ROOT xmlns:sql='urn:schemas-microsoft-com:xml-sql' >`
`<sql:query>`
`select * from table where field = <b>'1241&'`</b>
`</sql:query>`
`</ROOT>` into xml_out .
i was looking for a utility class withing ABAP to do this kind of conversion but didnt find anything so far.
If i come across anything i will let you know.
Regards
Raja
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hows the xml received into your program?
convert the input xml string to a xstring and try?
Regards
Raja
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.