How to convert XML doc to string and vice versa?
Assume I have a XML doc and I want to convert it into a string (and put it into a string variable).
How can I do this?
How can I do the opposite: Convert a string content into a XML doc?
Peter
Use:
ParseEscapedXML() and ora:getContentAsString()
See
http://www.codeguru.com/cpp/sample_chapter/article.php/c10789__7/
Marc
Similar Messages
-
How to convert ascii value into character and vice versa
Hello the java world people,
I want to convert each characters from my array into their corespondent ascii value and vice versa, how can I do that ?The term "ASCII" is often used very loosely.
Java char values are UNICODE and the ASCII codes are indentical to UNICODE characters in the range 0 .. 127. UNICODE values 128 and above don't have coresponding ASCII values, though 128-255 corespond to ISO-8859-1 which is one of the encodings often called "extended ASCII".
As shown above you can covert between chars and coresponding int value simply with a cast, but you should be aware that the more exotic characters will not give you sensible values. -
Convert char to ascii code and vice versa
HI
Is there any function module to convert char to ascii code and vice versa.
Thanks in advanceHi,
be careful if you have unicode running in your system. URL_ASCII_CODE_GET is platform-dependent so it will return the internal HERX representation of the character in your system - which is hopefully and in most cases ASCII.
Under unicode, we use double-byte characters here. I tried this function and the result CHAR_CODE is '00' regardless what character I specify for TRANS_CHAR. But the coding is so simple I corrected resultig in this sample code:
[P]
convert p_form to ASCII (internal) representation
DATA:
l_ofs TYPE syfdpos,
l_len TYPE sy-linsz,
l_ascii TYPE i.
FIELD-SYMBOLS:
<x> TYPE x.
l_len = STRLEN( p_ascii ).
DO l_len TIMES.
l_ofs = sy-index - 1.
ASSIGN p_ascii+l_ofs(1) TO <x> CASTING.
l_ascii = <x>.
WRITE: l_ascii.
ENDDO.
[/P]
Here, for each character of string p_ascii, the internal (ASCII) representation is determined and written to the output list.
Regards,
Clemens -
In the final display list how can i change rows to columns and vice versa
in the final display list how can i change rows to columns and vice versa
It's Urgent
Thanks
BasuHai,
Check this following Threads,
converting rows to columns in internal tables
Re: logic- report to move columns to row in a list
Regards,
Padmam. -
Strange problem in converting between XML to string and vice versa
i have an application that needs to send an XML document
over the wire. For this reason, I need to convert the
doc into a String at the sending side and back to Doc
at the receiving side. This document is stored in a "CLOB"
column in a table in the database. I use XDK to retrieve
this entire row (including the CLOB - hence this is an XML
document which has a column that itself is an xml document in
string format - this is just the clob read in by XDK).
Thus the row looks like
<ROWSET>
<ROW>
<col1> A <col1>
<CLOB_COL> ..clob value of an xml doc..</CLOB_COL>
</ROW>
</ROWSET>
When I convert this document into String and back, one of the "<"
tags in the clob column document gets changed to "<" and hence
the parsing fails! I have used the latest label of the XDK build
to get the latest parser jar but still i have the same problem.
I am using the following routines for the conversion.
/* for converting document to string */
public static String convertToString(XMLDocument xml) throws
IOException
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
xml.print(pw);
String result = sw.toString();
return result;
/* for converting string to document */
public static XMLDocument convertToXml(String xmlStr)
throws
IOException,SAXException
ByteArrayInputStream inStream = new
ByteArrayInputStream(xmlStr.getBytes());
DOMParser parser = new DOMParser();
parser.setPreserveWhitespace(false);
parser.parse(inStream);
return parser.getDocument();How do you get the XML document? Do you use XSU? You can use:
String str = qry.getXMLString();
to get the result XML document in String.
XSU will escape all of the < and >. Or the the XML document in
one of the column will make the result XML doc not well-formed.
Not quite understand your problem. You can send me your test
case.
i have an application that needs to send an XML document
over the wire. For this reason, I need to convert the
doc into a String at the sending side and back to Doc
at the receiving side. This document is stored in a "CLOB"
column in a table in the database. I use XDK to retrieve
this entire row (including the CLOB - hence this is an XML
document which has a column that itself is an xml document in
string format - this is just the clob read in by XDK).
Thus the row looks like
<ROWSET>
<ROW>
<col1> A <col1>
<CLOB_COL> ..clob value of an xml doc..</CLOB_COL>
</ROW>
</ROWSET>
When I convert this document into String and back, one of the "<"
tags in the clob column document gets changed to "<" and hence
the parsing fails! I have used the latest label of the XDK build
to get the latest parser jar but still i have the same problem.
I am using the following routines for the conversion.
/* for converting document to string */
public static String convertToString(XMLDocument xml) throws
IOException
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
xml.print(pw);
String result = sw.toString();
return result;
/* for converting string to document */
public static XMLDocument convertToXml(String xmlStr)
throws
IOException,SAXException
ByteArrayInputStream inStream = new
ByteArrayInputStream(xmlStr.getBytes());
DOMParser parser = new DOMParser();
parser.setPreserveWhitespace(false);
parser.parse(inStream);
return parser.getDocument(); -
Help needed XML to Internal table and vice versa
Hello frnds, I need to convert Internal table to XML and Vice versa.
Now I am able to most of the part except for this...
the xml which I have to generate looks something like this...
- <trade_dt>
- <![CDATA[ 20111108000000:20111108235959
]]>
</trade_dt>
its a range I think
And then the reponse which I get back the XML is like
- <lockinfo>
- <![CDATA[
TRD_HEADER 1045 1 2
ACT_CASHFLOW 1042 1
TRD_TERM 1045 2
]]>
</lockinfo>
Is there any provision in class cl_ixml or class if_ixml_element to handle this part.....
Edited by: Amit Sawant on Dec 28, 2011 3:51 PMHello Amit,
I would suggest you, to use the XSL-Transformations, which can be inbound used in ABAP.
For example:
DATA:
l_xml TYPE string,
lt_flights TYPE TABLE OF SFLIGHT.
SELECT * FROM SFLIGHT INTO TABLE LT_FLIGHT.
CALL TRANSFORMATION id
SOURCE DATA = lt_flights
RESULT XML l_xml.
Now, you have a XML-String which is in the ABAP-XML Notation, which means, that ABAP can move this XML-Data back into an internal table/structure.
For the backward, you have to use the following statement:
CALL TRANSFORMATION id
SOURCE XML l_xml
RESULT DATA = lt_flights.
As you will see, it is very easy. The Transformation "id" is just one example and build in. When you have to transform the data, or do not want to have the ASX-Notation in it, you should at least define your own transformations with the transaction XSLT_TOOL and use it similar to the transformation "id".
Kind Regards,
Hendrik -
How to convert UIView object to NSData and vise-versa for saving it in database using sqlite
I am using sqlite for my project which stores all the data including text fields , id , and one UIVIew object in a column having BLOB datatype .
Now while retriving the data i use
const char *raw = sqlite3_column_blob(selectstmt, 3);
int rawLen = sqlite3_column_bytes(selectstmt, 3);
NSData *data = [NSData dataWithBytes:raw length:rawLen];
view =[NSKeyedUnarchiver unarchiveObjectWithData:data];
where data is NSData obj n view is UIView obj ,
also while inserting data i use ,
NSData *data=[[NSData alloc]init];
data=[NSKeyedArchiver archivedDataWithRootObject:view];
// [data dataForView:notes.view];
sqlite3_bind_blob(updateStmt, 2, [data bytes], [data length], SQLITE_TRANSIENT);
But this is not working properly ... the Data object is giving some length,
while using the view the view object is null
is there any other solution to do the same ?There's a ton of information here: [http://www.json.org/] and I can't believe you didn't find that site yourself.
-
Upload XML to internal table and vice versa in SAP 4.6C
Hi,
Happy New Year to you all!
We are using 46C and I am beginning to learn about XML. We have a requirement to (1) upload an XML file into an internal table as well as (2) create an XML file from an internal table.
I read some of the posted messages about this but they didn't seem to be applicable in 46C (I could be wrong).
Could someone please help me using the sample file below?
<?xml version="1.0" ?>
- <AUCTIONBLOCK>
- <ITEM>
<TITLE>Still Life / Onions</TITLE>
<ARTIST>Linda Mann</ARTIST>
<DIMENSIONS>20x30 inches</DIMENSIONS>
<MATERIALS>Oil</MATERIALS>
<YEAR>1997</YEAR>
<DESCRIPTION>Still Life</DESCRIPTION>
<TIMESTAMP>1974</TIMESTAMP>
</ITEM>
</AUCTIONBLOCK>
Many thanks,
RosemarieHi,
Yes I'm on 4.6c. I've to comment several lines. Here is an example:
*& Report z_xit_xml_check
report z_xit_xml_check.
class cl_ixml definition load.
type-pools: ixml.
types: begin of t_xml_line,
data(256) type x,
end of t_xml_line,
begin of tsfixml,
data(1024) type c,
end of tsfixml.
data: l_ixml type ref to if_ixml,
l_streamfactory type ref to if_ixml_stream_factory,
l_parser type ref to if_ixml_parser,
l_istream type ref to if_ixml_istream,
l_document type ref to if_ixml_document,
l_node type ref to if_ixml_node,
l_xmldata type string.
data: l_elem type ref to if_ixml_element,
l_root_node type ref to if_ixml_node,
l_next_node type ref to if_ixml_node,
l_name type string,
l_iterator type ref to if_ixml_node_iterator.
data: l_xml_table type table of t_xml_line,
l_xml_line type t_xml_line,
l_xml_table_size type i.
data: l_filename type string.
parameters: pa_file type char1024 default
'd:joaodesenvolvimentos i act este.xml'.
Validation of XML file: Only DTD included in xml document is supported
parameters: pa_val type char1 as checkbox.
start-of-selection.
Creating the main iXML factory
l_ixml = cl_ixml=>create( ).
Creating a stream factory
l_streamfactory = l_ixml->create_stream_factory( ).
Regards,
Maria João Rocha
perform get_xml_table changing l_xml_table_size l_xml_table.
wrap the table containing the file into a stream
l_istream = l_streamfactory->create_istream_itable( table =
l_xml_table
size =
l_xml_table_size ).
Creating a document
l_document = l_ixml->create_document( ).
Create a Parser
l_parser = l_ixml->create_parser( stream_factory = l_streamfactory
istream = l_istream
document = l_document ).
Validate a document
if pa_val eq 'X'.
l_parser->set_validating( mode = if_ixml_parser=>co_validate ).
endif.
Parse the stream
if l_parser->parse( ) ne 0.
if l_parser->num_errors( ) ne 0.
data: parseerror type ref to if_ixml_parse_error,
str type string,
i type i,
count type i,
index type i.
count = l_parser->num_errors( ).
write: count, ' parse errors have occured:'.
index = 0.
while index < count.
parseerror = l_parser->get_error( index = index ).
i = parseerror->get_line( ).
write: 'line: ', i.
i = parseerror->get_column( ).
write: 'column: ', i.
str = parseerror->get_reason( ).
write: str.
index = index + 1.
endwhile.
endif.
endif.
Process the document
if l_parser->is_dom_generating( ) eq 'X'.
perform process_dom using l_document.
endif.
*& Form get_xml_table
form get_xml_table changing l_xml_table_size type i
l_xml_table type standard table.
Local variable declaration
data: l_len type i,
l_len2 type i,
l_tab type tsfixml,
l_content type string,
l_str1 type string,
c_conv TYPE REF TO cl_abap_conv_in_ce,
l_itab type table of string.
l_filename = pa_file.
upload a file from the client's workstation
call method cl_gui_frontend_services=>gui_upload
exporting
filename = l_filename
filetype = 'BIN'
importing
filelength = l_xml_table_size
changing
data_tab = l_xml_table
exceptions
others = 19.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
Writing the XML document to the screen
CLEAR l_str1.
LOOP AT l_xml_table INTO l_xml_line.
c_conv = cl_abap_conv_in_ce=>create( input = l_xml_line-data
*replacement = space ).
c_conv->read( IMPORTING data = l_content len = l_len ).
CONCATENATE l_str1 l_content INTO l_str1.
ENDLOOP.
l_str1 = l_str1+0(l_xml_table_size).
SPLIT l_str1 AT cl_abap_char_utilities=>cr_lf INTO TABLE l_itab.
WRITE: /.
WRITE: /' XML File'.
WRITE: /.
LOOP AT l_itab INTO l_str1.
REPLACE ALL OCCURRENCES OF cl_abap_char_utilities=>horizontal_tab
*IN
l_str1 WITH space.
WRITE: / l_str1.
ENDLOOP.
WRITE: /.
endform. "get_xml_table
*& Form process_dom
form process_dom using document type ref to if_ixml_document.
data: node type ref to if_ixml_node,
iterator type ref to if_ixml_node_iterator,
nodemap type ref to if_ixml_named_node_map,
attr type ref to if_ixml_node,
name type string,
prefix type string,
value type string,
indent type i,
count type i,
index type i.
data: name2 type string,
name_root type string,
node_parent type ref to if_ixml_node,
node_root type ref to if_ixml_node,
num_children type i.
node ?= document.
check not node is initial.
uline.
write: /.
write: /' DOM-TREE'.
write: /.
if node is initial. exit. endif.
create a node iterator
iterator = node->create_iterator( ).
get current node
node = iterator->get_next( ).
loop over all nodes
while not node is initial.
indent = node->get_height( ) * 2.
indent = indent + 20.
num_children = node->num_children( ).
case node->get_type( ).
when if_ixml_node=>co_node_element.
element node
name = node->get_name( ).
nodemap = node->get_attributes( ).
node_root = node->get_root( ).
name_root = node_root->get_name( ).
write: / 'ELEMENT :'.
write: at indent name color col_positive inverse.
write: 'NUM_CHILDREN:', num_children.
write: 'ROOT:', name_root.
node_parent = node->get_parent( ).
name2 = node_parent->get_name( ).
write: 'NAME2: ' , name2.
if not nodemap is initial.
attributes
count = nodemap->get_length( ).
do count times.
index = sy-index - 1.
attr = nodemap->get_item( index ).
name = attr->get_name( ).
prefix = attr->get_namespace_prefix( ).
value = attr->get_value( ).
write: / 'ATTRIBUTE:'.
write: at indent name color col_heading inverse, '=',
value color col_total inverse.
enddo.
endif.
when if_ixml_node=>co_node_text or
if_ixml_node=>co_node_cdata_section.
text node
value = node->get_value( ).
write: / 'VALUE :'.
mjprocha
node_parent = node->get_parent( ).
write: at indent value color col_group inverse.
name2 = node_parent->get_name( ).
write: 'NAME2: ' , name2.
endcase.
advance to next node
node = iterator->get_next( ).
endwhile.
endform. "process_dom -
How to access MYSQL from Oracle 10g and vice versa
I will like to know how do I create a database link between Oracle 10g and MYSQL database on windows. I have been saddled with responsibility of ensuring the communications between the 2 databases and I have searched everywhere on google, I could not find anywhere where this is explain explicitly and made work.
THank youIn general Oracle offers 2 different products to connect from an Oracle database to a MS SQL Server. The first product is for free and it is called
As DG4ODBC is a generic connectivity based on ODBC it allows you to connect to many foreign databases as long as you have a suitable ODBC driver.It for example allows you to read from text files but also connect to foreign databases like MS SQL Server or IBM DB2. Due to this wide variety of foreign data sources tha capabilities of DG4ODBC are very limited. It only supports a few Oracle functions that it can directly map to foreign database equivalents. All other functions will be post processed. Post processing means that ALL records from the foreign table(s) will be fetched into the Oracle database and the result is then processed locally - so depending on the amount of data stored in the foreign database it might take a while.
To be complete here some notes to follow up:
This Oracle support note describes possible options you have to connect to a foreign database:
Document 233876.1 Options for Connecting to Foreign Data Stores and Non-Oracle Databases - For example - DB2, SQL*Server, Sybase, Informix, Teradata, MySQL
So you see, to connect from Oracle to MySQL you need to use the Database gateway for ODBC release 11.2 (HSODBC which was shipped with 10g was desupported in march 2008).
The Database Gateway for ODBC 11.2 (=DG4ODBC) license is included in the Oracle database license and it allows you to connect with a suitable 3rd party ODBC driver to a foreign database.
For your MySQL connection you only need to download and configure the MySQL ODBC driver from the MySQL web site. Once you can connect with the ODBC driver you could then download and configure DG4ODBC.
As you didn't post on which platform your Oracle database is installed, here 2 notes for common platforms:
How to Configure DG4ODBC on 64bit Unix OS (Linux, Solaris, AIX, HP-UX Itanium) to Connect to Non-Oracle (Doc ID 561033.1)
How to Configure DG4ODBC (Oracle Database Gateway for ODBC) on 64bit Windows Operating Systems to Connect to Non-Oracle Databases Post Install (Doc ID 1266572.1)
- Klaus -
Formatting is off when opening Word docs in Pages and vice versa
I recently decided to switch from Windows to Mac and bought a MacBook. I used to use Word on my Windows computer and now when I open .doc or .docx files in Pages, the formatting is off, i.e. bullets, tabs, spacing, etc. This formatting problem also happens when other people use Word to open my files that I created in Pages and saved as a .doc. Is there some fix for this so that I don't have to reformat each document that was created in Word but that I now open in Pages?
For maximum compatibility I think you need to use Word for Mac or OpenOffice.
-
Converting PC data to AppleWorks and vice versa
Background: I am working with a high school reunion class administrator who has emailed me a mailing list file in a PC Excell spreadsheet format. I can read this in AppleWorks (6). He is asking me to put this in a database format where we can use this for mailing labels. He is asking me to send this back to him in MS Works format (He has PC MS Works not Mac MS Works) however he is using an Intel Mac preferring the Windows XP over OSX. I do not have MS Works only AppleWorks. Is all the above possible with AppleWorks? Can I put the data from the spreadsheet into a database format, and does that require I cut and paste everything? Once I get it into an AppleWorks database how do I put it into MS Works database format or something he can read into MS Works database format, and email it to him? First time experimenting with this and hope it will work out. Thanks in advance for any help. CAB
Mac mini Intel/iBook G3 Mac OS X (10.4.5) Mac OSX (10.3.5) for iBookMy open question is how to take Excel data (.xls) and make a Apple Works database file? Must I cut and paste each name, address, phone #, email from Excel to Appleworks DB? Is there any other way?
You should be able to copy and paste the entire data set in one move, provided you have an AppleWorks DB set up to receive the data.
Create the AW DB, adding the fields in the same order as the columns of the Excel spreadsheet.
Open the spreadsheet in Excel or as an AppleWorks spreadsheet.
Select and copy all of the block of cells containing data.
Click on the first (empty) record of the database document so the the whole record is highlighted (ie. click on the record, but not in a field, or in List view, click on the small square to the left of the first row), then Paste.
Your data should be pasted in, creating one record in the DB for each line on the spreadsheet.
Regards,
Barry -
How to convert from UNICODE (UTF16) to UTF8 and vice-versa in JAVA.
Hi
I want to insert a string in format UTF16 to the database. How do I convert from UTF16 to UTF8 and vice- versa in JAVA?. What type must the database field be? Do I need a special set up for the database (oracle 8.i)?
thanks
nullI'm not sure if this is the correct topic, but we are having problems accessing our Japanese data stored in UTF-8 in our Oracle database using the JDBC thin driver. The data is submitted and extracted correctly using ODBC drivers, but inspection of the same data retrieved from the GetString() call using the JDBC thin driver shows frequent occurrences of bytes like "FF", which are not expected in either UTF8 or UCS2. My understanding is that accessing UTF8 in Java should involve NO NLS translation, since we are simply going from one Unicode encoding to another.
We are using Oracle version 8.0.4.
Can you tell me what we are doing wrong?
null -
How to convert XML into word doc or pdf
hi all ,
i ve to create a xml with specified alignment,but while taking print out alignments changing according to IE's alignment.
So, Plz some one tel me whether any solution is there in xml itself or it have to be convert into word doc or PDF.If so, tell me an idea for how to convert xml file into Word doc or PDF.thanx ,i saw about FOP in xml.apache.org site and i learned something abt tat . But i dont know how to download FOP package from apache..
Actually they gave links to download
like http://ftp.wayne.edu/apache/xml/fop
inside tat link they mentioned as parent,Directory,binaries,sources and tar files.From this i dont know how to download?
Plz can someone tell a solution.. -
How to convert a data set into a xml data and vice versa
i am new to oracle with xml..
my aim is to convert a data set into a xml data and vice versa..
my work is as follows...
my query:
select rggpk,rggcode,rggname from ms_regiongeo
to convert a data set into a xml*
select XMLType(trim(replace(dbms_xmlgen.getXML('select rggpk,rggcode, rggname from ms_regiongeo'),'<?xml version="1.0"?>',''))) XML_DATA from dual;
(this works fine and output of this query is as follows..)
<ROWSET>
<ROW>
<RGGPK>201</RGGPK>
<RGGCODE>Asia</RGGCODE>
<RGGNAME>Asia</RGGNAME>
</ROW>
<ROW>
<RGGPK>1</RGGPK>
<RGGCODE>OTH</RGGCODE>
<RGGNAME>Others</RGGNAME>
</ROW>
<ROW>
<RGGPK>21</RGGPK>
<RGGCODE>COB</RGGCODE>
<RGGNAME>Africa and Yemen</RGGNAME>
</ROW>
<ROW>
<RGGPK>2</RGGPK>
<RGGCODE>AUS</RGGCODE>
<RGGNAME>Australia</RGGNAME>
</ROW>
<ROW>
<RGGPK>23</RGGPK>
<RGGCODE>IND</RGGCODE>
<RGGNAME>Indian Sub Continent</RGGNAME>
</ROW>
<ROW>
<RGGPK>24</RGGPK>
<RGGCODE>TVM</RGGCODE>
<RGGNAME>North America</RGGNAME>
</ROW>
</ROWSET>
and to reverse this process, I tried a query like this..*
select EXTRACTVALUE (XML_DATA,'ROWSET/ROW/RGGPK') as EMP_ID
from(
select XMLType(trim(replace(dbms_xmlgen.getXML('select rggpk,rggcode, rggname from ms_regiongeo'),'<?xml version="1.0"?>',''))) XML_DATA from dual
)tab1but failed.. and raised with an eror: ORA-19025
help me..
regards,
johnHi-
my aim is to convert a data set into a xml data You can refer to the below posts
Adding namespace to XML output
Re: how to convert table data in xml format based on the xsd. -
How to convert XML into XSD Using Altova XML Spy
Hi,
How to convert XML file into XSD Using Altova XML Spy.
I want to use that XSD as an External Def in my IR
Regards
Sumanhi
Following is the path where you could get the PDF's and zip file.
https://www.sdn.sap.com/irj/sdn/howtoguides?rid=/webcontent/uuid/5024a59a-4276-2910-7580-f52eb789194b [original link is broken]
please check out the following Heading, and at the bottom corner you will find the download option where you will get the zip file:
How to Generate XSD Schemas from Existing MDM 5.5 Repositories
You can download xomlite45.jar from sdn
copy the jar file to your java installation location like c:>java in
Java jar xomLite45.jar MyFile.xml
then you get correspondig MyFile.xsd
https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/bf0e8a97-0d01-0010-f0a2-af3b18b7f4eb
Maybe you are looking for
-
How do I turn off pop up blockers on my ipad2?
How. Do o turn off pop up blockers on my iPad 2?
-
Changing Page size in Adobe forms
Hi Experts, I am new to Adobe forms.I am creating a form whose size is very small with 11.6929In height and 8.2677In width.But i viewed some of the SAP standard reports for example FITP_PLAN_FORM ,the page size is 29.7cm and 21cm width the page type
-
Software Update keeps timing out on QuickTime 7.1.6
Three different Macs (MacBook, MacBook Pro, iMac PPC) all with the same problem. Software updater times out, downloading directly from apple.com has the same problem. Updater downloads other updates, can download Quicktime for Windows with no issues.
-
Updating iphone using shared itunes account
Recently I updated both my husband and my iphone4's to new software using my itunes account. My iphone updated succesfully, but when his was finished all of my contacts are now on his phone, as well as my text messages, and pictures. NONE of his pi
-
How do you add into a group a contact you added onto your i-phone?
How do I put into a group a contact I added to my i-phone 6?