How To Convert XML into String?
Hi,
I have a requirement in which I need to convert the data from XML file to string.
E.g.
<Drawing>
<DrawingSpecification>
<Header>
<SoldTo>SDN</SoldTo>
<SoldToName>SAP</SoldToName>
<Date/>
<Manager>CEO</Manager>
< Plant>INDIA</Name>
<Items>
<Item>
< MaterialNumber>MatNum12</ MaterialNumber>
<ProductNumber>ProName12</ ProductNumber>
</Item>
</Items>
< ClientId>ClientID123</ ClientId>
<FileName>FileName123</FileName>
<Type/>
< TemplateName/>
</DrawingSpecification>
<Image contentType=""/>
< /Drawing>
Output should be like:
< File>
< Content> SDN SAP CEO INDIA MatNum12 ProName12 ClientID123 FileName123</Content>
< /File>
Please provide solution for the same.
Thanks,
Abhishek.
what about something like this
package test;
import java.io.File;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class Test {
public static void main(String args[]) throws Exception {
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
Document doc = docBuilder.parse(new File("test.xml"));
StringBuffer buffer = new StringBuffer();
appendChildren(buffer, doc.getChildNodes());
System.out.println(buffer.toString());
private static void appendChildren(StringBuffer buffer, NodeList list) {
for (int i = 0; i < list.getLength(); i++) {
Node node = list.item(i);
if (node.getNodeValue() != null) {
if (node.getNodeValue().trim().length() > 0) {
buffer.append(node.getNodeValue()).append("|");
appendChildren(buffer, node.getChildNodes());
...btw: IMHO the use of this forum is to get an answer to an particular question - not to ask for complete solutions - create the solution yourself an ask if you are stuck somewhere (with a bit of research (google) it is not hard to find a solution for your problem)
regards franz
...close thread if question is answered
Similar Messages
-
How to convert byte into string
can any tell me how to convert byte into string
when im an debugging thid code in eclipse it shows the result in integer format instead of string but in command prompt it is showing result in string format..........plz help
package str;
import java.io.*;
public class Testfile {
public static void main(String rags[])
byte b[]=new byte[100];
try{
FileInputStream file=new FileInputStream("abc.txt");
file.read(b,0,50);
catch(Exception e)
System.out.println("Exception is:"+e);
System.out.println(b);
String str=new String(b);
System.out.println(str);
}Namrata.Kakkar wrote:
errors: count cannot be resolved and Unhandled exception type Unsupported Encoding Exception.
If i write an integer value instead of "count" then Unhandled exception type Unsupported Encoding Exception error is left.This is elementary. You need to go back to [http://java.sun.com/docs/books/tutorial/|http://java.sun.com/docs/books/tutorial/] . -
How to Parse XML into String in BPEL?
Hi,
Can anyone tell me, how can I parse XML into String?
I am taking input from File Adapter, File adapter is reading that XML.
Then in assign activity i am using XPath expression(built functions) using XMLParser(),doTranslateToNative() etc.. many functions I have tried but XML is not getting parsed into String Variable.
Please help me asap.
Thanks
ShikhaThanks a lot Eric.
I am trying this, oraext:get-content-as-string('receiveInput_Read_InputVariable','body','/ns3:orders')
but getting this error
<bpelFault><faultType>0</faultType><subLanguageExecutionFault xmlns="http://schemas.oracle.com/bpel/extension"><part name="summary"><summary>XPath expression failed to execute. An error occurs while processing the XPath expression; the expression is oraext:get-content-as-string('receiveInput_Read_InputVariable','body','/ns3:orders'). The XPath expression failed to execute; the reason was: internal xpath error. Check the detailed root cause described in the exception message text and verify that the XPath query is correct. </summary></part><part name="code"><code>XPathExecutionError</code></part></subLanguageExecutionFault></bpelFault> -
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 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 -
How to convert XML into idocs and post in ECC using PI
Hello All,
I want to configure the scenario like this MDM->PI->ECC. Using FTP I am getting able to fetch the xml file from MDM Server Ready folder. Now, I need to convert this XML file into Idocs and post it in ECC. Can anyone provide me step by step configuration in PI to achieve this. I have configured communication channel with adapter type Idoc in Itegration Builder. But, I am not sure where it will do the conversion of XML into Idoc and how do post it to ECC. I am working first time on PI 7.1. I have worked on XI 3.0 in 2006-2007. Any help to configure this step by step shall be appreciated.
Thanks & Regards,
HemalIn you have the XML from MDM you have to use the mapping provided by the funtionals in the Funtional specification documents. once you did it you must configure the Receiver IDoc Adapter. and later dont fonget to configure properly the ReceiverAgreement.
as you receive the docuement from MDM via FTP, thats not a SAP System that means that you have to define PI as the sender of the IDoc,otherwise you will have the Error "Unable to convert the sender service to an ALE logical system"
to do that in the receiver Agreement>Header Mapping>Sender System-->Select PI server.
Take in mind to send IDocs to any SAP System, the system that send it must be a SAP system too. thats why you configure it
http://help.sap.com/saphelp_nw04/helpdata/en/5d/112d20f6ce6c46ba66afb98d278fbd/frameset.htm
Another thing is you have configure the ALE distribution Model.
se this:
http://wiki.sdn.sap.com/wiki/display/XI/FileToIDOC
/people/michal.krawczyk2/blog/2005/03/29/xi-error--unable-to-convert-the-sender-service-to-an-ale-logical-system
/people/venugopalarao.immadisetty/blog/2007/01/24/troubleshooting-file-to-idoc-scenario-in-xi
Let us know
Rodrigo P-. -
How to convert filenames into strings
im listing a lists of files
using the method listFiles() which returns me data of type File which are actually
all files in the dir.
may i know how do i convert the filenames returned to become strings
so that i can manipulate the filenames as string format instead of file format?
thanks for any help suggested!Im encountering a problem now before i can test the method...
This the current problem i had :
i only showed part of the codes here:
File[] listing = Dir.listFiles();
String[] lists;
for (int i=0; i < listing.length; i++)
lists[i] = new String(listing.getName());
out.print(lists[i] + "<br>");
The error i had:
variable lists might not have been initialized
lists[i] = new String(listing[i].getName());
^
1 error
I forgot how to deal with String array...
I declare as String[] lists; coz i do not know the size of the array...
how do i assign the filenames to strings?
Please kindly help..thanks a lot! -
How to convert Objext[] into String[] or any other object
Hi,
I've happened to come across a weird problem in java 1.6. I am sure it was alright before. Here is what I want to do and the result is
Exception in thread "main" java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Ljava.lang.String;
Vector toVec = new Vector();
StringTokenizer addrs = new StringTokenizer(addressesTo,";");
while(addrs.hasMoreTokens()) {
toVec.add(new String(addrs.nextToken()));
String[] to;
Object[] obj = toVec.toArray();
to = (String[])obj;
the tokenizer has at least 1 item. I am sure of it.
Can anybody explain this phenomena?
Thanks.No, you did not use identical code before, or if you did, you got the same results.
String[] str[] = (String[])list.toArray(); // won't work, as toArray() returns Object[]
String[] str[] = (String[])list.toArray(new String[0]); // works, creates a new String[]
String[] str[] = (String[])list.toArray(newString[list.size()]); // works, returns a reference to the array created inline -
How to convert BLOB into a String
Hi,
I got a blob column from the database.
It contains one XML File.
How to convert it into String.
I need the code for how to convert the blob into String
Thanks in Advance.A blob would be a byte-array, which you can use in the String(byte[]) constructor
-
Convert xml into SAP using dataset
Hi All,
How to convert XML into itab using dataset, in this conversion have any function module available? please give me a sample program (having any). and material also.
Thanks,
Suresh maniarasuHi,
First you need to get the XML file Data into SAP using the Function Module and can populate the data into an inernal table.
TEXT_CONVERT_XML_TO_SAP
DMC_CONVERT_XML_TO_TABLE
or you can use the following classes
CL_RSRD_CONVERTER_XML
CL_WDR_XML_CONVERT_UTIL
CL_EXM_IM_ISHCM_CONV_XML_SAP
Thank U,
Jay.... -
How to convert idoc into xml/edifact
hi everyone just now i have started to work on edi, i want to kno how to convert idoc into xml/edifact. plz reply asap
Firstly, I will reply when and if I choose to. I do not require the asap nonsense at the end of your sentence.
EDIFACT - You will need a subsystem.
XML - I am not 100%. It may also depend on what version of SAP you are on. As I do not know if later versions of SAP can convert IDoc to XML. -
How to convert xml data into html format in bpel
Hi ,
Can any one tel me how to conevrt xml into html in oracle bpel.
Does bpel support this functionality or not.
Regards,
Ana
Edited by: user10181991 on Apr 5, 2009 11:16 PMAna,
We are doing the same thing--using one variable with the schema as the source of the .xsl and assigning the resulting html to another variable--the content body of the email, in our case. I just posted how we did it here: Re: Using XSLT to generate the email HTML body
Let me know if this helps. -
How to convert smartforms into Adobe forms.
Hi......
How to convert smartforms into Adobe forms.
Regards
Anbu BHi,
You need to use the Function Module CONVERT_OTF.
Please check the below code
REPORT zsuresh_test.
Variable declarations
DATA:
w_form_name TYPE tdsfname VALUE 'ZSURESH_TEST',
w_fmodule TYPE rs38l_fnam,
w_cparam TYPE ssfctrlop,
w_outoptions TYPE ssfcompop,
W_bin_filesize TYPE i, " Binary File Size
w_FILE_NAME type string,
w_File_path type string,
w_FULL_PATH type string.
Internal tables declaration
Internal table to hold the OTF data
DATA:
t_otf TYPE itcoo OCCURS 0 WITH HEADER LINE,
Internal table to hold OTF data recd from the SMARTFORM
t_otf_from_fm TYPE ssfcrescl,
Internal table to hold the data from the FM CONVERT_OTF
T_pdf_tab LIKE tline OCCURS 0 WITH HEADER LINE.
This function module call is used to retrieve the name of the Function
module generated when the SMARTFORM is activated
CALL FUNCTION 'SSF_FUNCTION_MODULE_NAME'
EXPORTING
formname = w_form_name
VARIANT = ' '
DIRECT_CALL = ' '
IMPORTING
fm_name = w_fmodule
EXCEPTIONS
no_form = 1
no_function_module = 2
OTHERS = 3
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Calling the SMARTFORM using the function module retrieved above
GET_OTF parameter in the CONTROL_PARAMETERS is set to get the OTF
format of the output
w_cparam-no_dialog = 'X'.
w_cparam-preview = space. " Suppressing the dialog box
" for print preview
w_cparam-getotf = 'X'.
Printer name to be used is provided in the export parameter
OUTPUT_OPTIONS
w_outoptions-tddest = 'LP01'.
CALL FUNCTION w_fmodule
EXPORTING
ARCHIVE_INDEX =
ARCHIVE_INDEX_TAB =
ARCHIVE_PARAMETERS =
control_parameters = w_cparam
MAIL_APPL_OBJ =
MAIL_RECIPIENT =
MAIL_SENDER =
output_options = w_outoptions
USER_SETTINGS = 'X'
IMPORTING
DOCUMENT_OUTPUT_INFO =
job_output_info = t_otf_from_fm
JOB_OUTPUT_OPTIONS =
EXCEPTIONS
formatting_error = 1
internal_error = 2
send_error = 3
user_canceled = 4
OTHERS = 5
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
t_otf[] = t_otf_from_fm-otfdata[].
Function Module CONVERT_OTF is used to convert the OTF format to PDF
CALL FUNCTION 'CONVERT_OTF'
EXPORTING
FORMAT = 'PDF'
MAX_LINEWIDTH = 132
ARCHIVE_INDEX = ' '
COPYNUMBER = 0
ASCII_BIDI_VIS2LOG = ' '
PDF_DELETE_OTFTAB = ' '
IMPORTING
BIN_FILESIZE = W_bin_filesize
BIN_FILE =
TABLES
otf = T_OTF
lines = T_pdf_tab
EXCEPTIONS
ERR_MAX_LINEWIDTH = 1
ERR_FORMAT = 2
ERR_CONV_NOT_POSSIBLE = 3
ERR_BAD_OTF = 4
OTHERS = 5
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
To display File SAVE dialog window
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
WINDOW_TITLE =
DEFAULT_EXTENSION =
DEFAULT_FILE_NAME =
FILE_FILTER =
INITIAL_DIRECTORY =
WITH_ENCODING =
PROMPT_ON_OVERWRITE = 'X'
CHANGING
filename = w_FILE_NAME
path = w_FILE_PATH
fullpath = w_FULL_PATH
USER_ACTION =
FILE_ENCODING =
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
NOT_SUPPORTED_BY_GUI = 3
others = 4
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Use the FM GUI_DOWNLOAD to download the generated PDF file onto the
presentation server
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
BIN_FILESIZE = W_bin_filesize
filename = w_FULL_PATH
FILETYPE = 'BIN'
APPEND = ' '
WRITE_FIELD_SEPARATOR = ' '
HEADER = '00'
TRUNC_TRAILING_BLANKS = ' '
WRITE_LF = 'X'
COL_SELECT = ' '
COL_SELECT_MASK = ' '
DAT_MODE = ' '
CONFIRM_OVERWRITE = ' '
NO_AUTH_CHECK = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
WRITE_BOM = ' '
TRUNC_TRAILING_BLANKS_EOL = 'X'
WK1_N_FORMAT = ' '
WK1_N_SIZE = ' '
WK1_T_FORMAT = ' '
WK1_T_SIZE = ' '
IMPORTING
FILELENGTH =
tables
data_tab = T_pdf_tab
FIELDNAMES =
EXCEPTIONS
FILE_WRITE_ERROR = 1
NO_BATCH = 2
GUI_REFUSE_FILETRANSFER = 3
INVALID_TYPE = 4
NO_AUTHORITY = 5
UNKNOWN_ERROR = 6
HEADER_NOT_ALLOWED = 7
SEPARATOR_NOT_ALLOWED = 8
FILESIZE_NOT_ALLOWED = 9
HEADER_TOO_LONG = 10
DP_ERROR_CREATE = 11
DP_ERROR_SEND = 12
DP_ERROR_WRITE = 13
UNKNOWN_DP_ERROR = 14
ACCESS_DENIED = 15
DP_OUT_OF_MEMORY = 16
DISK_FULL = 17
DP_TIMEOUT = 18
FILE_NOT_FOUND = 19
DATAPROVIDER_EXCEPTION = 20
CONTROL_FLUSH_ERROR = 21
OTHERS = 22
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Thanks,
Ruthra -
How to convert .class into .jar file
Hi,
How to convert .class into .jar filejsf_VWP5.5.1 wrote:
Hi,
How to convert .class into .jar fileFrom a command prompt, cd to the location of your .class file(s).
If you want to create a simple jar, use: jar -cf Whatever.jar Whatever.class
If you want to compile all .class files in a directory into a jar, use *.class instead.
Now, I'm going to assume you want to create an executable jar... here's how to do that:
1) Create a blank text file; for this example, lets call it main.txt.
2) In the first line of main.txt, type: Main-class: Whatever ('Whatever' should be the name of the class in your program where the main() method is located)
3) Press enter to go to the next line (someone please correct me if I'm wrong, but if you don't insert the line break/CR after the Main-class: statement, this will not work... in my experience, this is true)
4) Make sure you save this file in the same directory as your .class file(s).
5) Type: jar -cmf Whatever.jar main.txt Whatever.class
...and that's about it. For more information on the usage of the jar command and to understand the switches (such as -cmf), try jar --help.
Hope that helps. -
How to convert XML file to an internal table ?
Hi All,
I want to do a batch input program. The source data would be given as an excel file . I would like to know how to convert XML file to internal table properly. Please help me out..
Thanking you in advance ..
Shankara Narayanan T.VHi Shankar,
use 'ALSM_EXCEL_TO_INTERNAL_TABLE' FM.
CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
EXPORTING
filename = p_file1
i_begin_col = '1'
i_begin_row = '5'
i_end_col = '40'
i_end_row = '16'
TABLES
intern = it_intern
EXCEPTIONS
inconsistent_parameters = 1
upload_ole = 2
OTHERS = 3.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
LOOP AT it_intern.
AT NEW row.
CLEAR it_intern.
ENDAT.
CASE lv_flag.
Production Version
WHEN 1.
it_master-matnr = it_intern-value.
WHEN 2.
it_master-werks = it_intern-value.
WHEN 3.
it_master-verid = it_intern-value.
WHEN 4.
it_master-text1 = it_intern-value.
WHEN 5.
it_master-fdate = it_intern-value.
AT END OF row.
APPEND it_master.
ENDAT.
ENDLOOP.
-Anu
Message was edited by:
Anupama Reddy
Maybe you are looking for
-
i have one computer and 2 iphones i want to sync music on. but we want different music on the phones. is there a way i can make 2 libraries on 1 itunes?
-
Unable to start managed console - unix
I'm having problems starting a managed server in Unix -- using the startManagedWebLogic.sh, with the weblogic name of the managed server and http://adminIP:port as the parameters. Saying it can't find the managed server. Is this some type of access p
-
Usage of to_date & to_char
pls. give advanced usage of to_date & to_char
-
This page: https://secure.skype.com/account/usage has been broken for quite a while now.
-
How disable the full screen option in the standard or wireframe video player ?
I was wondering if (and how) it's possible to just disable the full screen option in the controls that appear below the video player (standard or wireframe). I want to have a video player with the progression bar, play / pause options, the counter wi