To format string like xml

Hi,
i have a string which has a xml content:
String myXML = "<xml><test>Test</test></xml>";
With log4j i produce a trace file with the output of String a: Log.info(myXML);
Unfortunately the content of xml data is verly long and its difficult to read it.
I would like to have the string to be xml formatted like:
<xml>
<test>Test</test>
</xml>
how to manage it?
Thanks

Your best bet might to be getting a 'tidy' program for xml. Most xml editors can very cleanly re-structure xml to collapsible nodes.
Also you could try some proactive logging logic;
after a closing tag, add a \n to return a new line, this will help most editors make it display nicely.

Similar Messages

  • Format String using XML attributes

    I need to format a string based on attributes from a schema. I am attempting to do this using an Assign activity and the java embedded format string function. Here is a simplified version of what I am trying to do:
    oraext:format-string('Service Error COD={0}', bpws:getVariableData('caXMLError','/CAXMLERROR/CLIERR/@COD'))
    When I execute this line I get:
    XPath expression failed to execute. An error occurs while processing the XPath expression; the expression is oraext:format-string('Service Error COD={0} ',bpws:getVariableData('caXMLError','/CAXMLERROR/CLIERR/@COD')). The XPath expression failed to execute;
    The value at bpws:getVariableData('caXMLError','/CAXMLERROR/CLIERR/@COD' is valid because I can create a dummy xsd:string variable and set it equal to that.
    I also tried to wrap the getVariableData with the get_content_as_string methods and neither worked. I also verified that my format-string function is working because when I substitute just a plain string like ‘T01’ the string is successfully created.
    Any ideas what I am doing wrong or how I can accomplish this?

    If the xml document is to be stored in the Oracle database with the XML SQL Utility, defne elements instead of attributes. XSU utility does not map the attributes of an xml document to the database table.
    Further ref:
    http://xml.coverpages.org/elementsAndAttrs.html

  • Parsing formatted String to Int

    How can I parse formatted string to Integer ?
    I have a formated string like this $900,000 and I need to convert it to 900000 so I could do calculations with it.
    I tried something like this
    NumberFormat nf = NumberFormat.getIntegerInstance(request.getLocale());
    ttlMargin=nf.parse(screenVal);I got this exception
    "java.lang.NumberFormatException: For input string: "$1,050,000""

    I am working on the JSP file that provides
    margins,sales etc. I am reading this data off the
    screen where it is beeing displayed according to the
    accounting practices.
    That's why I get it as a formatted string and why I
    am trying covert that string to the numberScreen-scraping is a problematic, bad design. It sounds like what you really want is to call a web service which returns its results as data that a program can understand (XML, for example), not HTML (which is meant more for humans to read). I know, you probably can't change the design at this point... just food for thought. In the meantime, you'll probably have to manually parse those strings yourself by stripping out the '$' and ',' characters and then use parseInt on the result.

  • Formatting strings

    I'm new to Java and I couldn't find a method/class to format strings like the old C-style sprintf().

    There are several classes to format specific types of objects. If you said what you were actually trying to do (the first question) instead of what would be the equivalent of a construct in some other language (the second question) an answer would probably appear.

  • Converting String To XML Format and send as attachment

    Hi
    My requirement is to convert String into XML Format and that XML File i have to send as an attachment
    can any one one give solution for this Problem.
    Thank you
    Venkatesh.K

    hi,
    i m filling the itab first and converting to xml
    itab contaning these data
    GS_PERSON-CUST_ID   = '3'.
    GS_PERSON-FIRSTNAME = 'Bill'.
    GS_PERSON-LASTNAME  = 'Gates'.
    APPEND GS_PERSON TO GT_PERSON.
    GS_PERSON-CUST_ID   = '4'.
    GS_PERSON-FIRSTNAME = 'Frodo'.
    GS_PERSON-LASTNAME  = 'Baggins'.
    APPEND GS_PERSON TO GT_PERSON.
    after conversion data is coming like that
    #<?xml version="1.0" encoding="utf-16"?>
    <CUSTOMERS>
      <item>
        <customer_id>0003</customer_id>
        <first_name>Bill</first_name>
        <last_name>Gates</last_name>
      </item>
      <item>
        <customer_id>0004</customer_id>
        <first_name>Frodo</first_name>
        <last_name>Baggins</last_name>
      </item>
    </CUSTOMERS>
    but errors are  1) # is coming at the first
                            2)for 'encoding="utf-16"?>', it is not coming perfectly, some other data (iso-8859-1) should come here
    can anybody plz solve it.
    regards,
    viki

  • Converting string to XML format

    Hi All,
    I have a requirement to convert string to xml format and download it. Atpresent, I have a string which is a collection of xml tags. I want to convert this string to xml format like <VALUE004>20387899.437</VALUE004>
    <VALUE005>20387899.437</VALUE005>
    <VALUE006>20387899.437</VALUE006>
    Is there any function module for this.

    Chk this thread.
    Re: Regd: File Conversion to XML format

  • Parse XML formatted String

    Hi All,
       I have a string field that is formatted in XML format. What I want to be able to do is pull a specific element from the xml formatted string.
    Example string:
    <customer><name>john</name><id>25636</id></customer>
    I want to retreive just the id number of 25636 from this string.
    I would I go about accomplishing this?
    Thank you in advance,

    I fixed it on my own.
    Here' s my answer for others that may need it:
    if(instr({field.xmlstring},'</id>')  - instr({field.xmlstring},'<id>') = 7)then
       mid(totext({field.xmlstring}),instr({field.xmlstring},'<id>')+4,3)
    else if(instr({field.xmlstring},'</id>')  - instr({field.xmlstring},'<id>') = 8)then
       mid(totext({field.xmlstring}),instr({field.xmlstring},'<id>')+4,4)
    else if(instr({field.xmlstring},'</id>')  - instr({field.xmlstring},'<id>') = 9)then
       mid(totext({field.xmlstring}),instr({field.xmlstring},'<id>')+4,5)
    I use the conditions to cover all possible lengths of the id number.

  • Any way to format text in xml

    hi guys,
    I have a photogallery done in flash. Its having a external
    xml file where the descriptions and image location is defined. Is
    there any way to add font color , font size , and all other font
    formating options inside the xml file to take effect inside flash
    movie. I have tried cddata , <b> , <fontface> etc
    etc... but no result. Please any one help

    you can write the html format string in the xml node just
    like normal - however you must apply the string to a textField that
    has it's html property set to true and you must use field.htmlText
    to assign the string, as in:
    field.html = true;
    field.htmlText = "<b>bold text</b>";

  • Error: ORA-01861: literal does not match format string

    Hi,
    I am doing a RFC-XI-JDBC scenario.
    In the CC monitoring , i am getting this error for the reciver CC:
    "Error while parsing or executing XML-SQL document: Error processing request in sax parser: Error when executing statement for table/stored proc. "TableNAMe"(structure 'STATEMENTNAME'): java.sql.SQLException: ORA-01861: literal does not match format string "
    Please guide me what can be the cause and how to solve it.
    Thanks,
    Puneet

    This is how my payload looks like :
    <?xml version="1.0" encoding="UTF-8"?>
    <ns1:MT_JDBC_REC xmlns:ns1="https:namespace.scene3">
    <STATEMENTNAME>
    <TABLE_NAME action="INSERT">
    <TABLE>ggclgis</TABLE>
    <access>
    <VALVE_ID>12584</VALVE_ID>
    <EQUNR>122</EQUNR>
    <ERNAM>12122</ERNAM>
    <INVNR>1212</INVNR>
    <GROES>1212</GROES>
    <ELIEF>123</ELIEF>
    <GWLEN>21-jul-2008</GWLEN>
    <GWLDT>12-jun-2006</GWLDT>
    <SERGE>wqwqw</SERGE>
    <TYPBZ>wqwqwq</TYPBZ>
    </access>
    </TABLE_NAME>
    </STATEMENTNAME>
    </ns1:MT_JDBC_REC>
    Please tell me if it looks fine.

  • How to convert a string into xml file

    Hi,
    i have a string . the string contain fully formated xml data. i mean my string like below
    <?xml version="1.0"?>
    <PARTS>
       <TITLE>Computer Parts</TITLE>
       <PART>
          <ITEM>Motherboard</ITEM>
          <MANUFACTURER>ASUS</MANUFACTURER>
          <MODEL>P3B-F</MODEL>
          <COST> 123.00</COST>
       </PART>
       <PART>
    ......................i want to convert it into an xml file
    can u help me?
    thank u

    Thank you Paul Clapham,
    and sorry ..
    i have some other doubt.. regarding xml
    i want to post an XML file from one server(Server_1) to other server.(Server_2)
    To generate an xml file i used DOM in Server_1.
    using xml.transform , StringWriter i converted it into String.
    I post the string to another server and there i will parse it.
    for that i write the code like below in servlet in server_1
    <form name=fn action=http://localhost:8080/server_2/parseXMl.do method=post>
    <input type=hidden name=xmlFile value="+Xmlstring+">
    <input type=submit >is this process is correct?
    Some of the turorial told that use web-services/XML-RPC
    but i new to both..
    I want to complete it using my knowledge only/
    Is it possible to do it?
    Or any other alternative?
    can help me?

  • OSB: fn-bea:inlinedXML format my signed XML

    Hello.
    I'm trying to replace my output xml message with the same message, but digitally signed.
    My proxy flow looks like:
    1. Call to BS.
    2. In response, take the output from BS and digitally sign it (Service callout to a signing service).
    3. Take the output from that service (it returns the signed xml into a "CDATA" section).
    4. Extract the xml (CDATA), and call to fn-bea:inlinedXML
    5. Substitute the output message with the xml in point 4).
    But "inlinedXML" seems to format the xml string (whitespace, line breaks,...), so the sign is no longer valid.
    ¿Can OSB convert from string to xml without formatting?.
    Thanks.

    Hello.
    Does anyone knows how to tell OSB to stop formatting my XML?.
    Thanks.

  • String to XML

    Hi everyone,
    i'm just writing a method, that gets a string and a XPath and want writes the string to the specific XPath in my xml document. The problem ist, that the string itself can contain nodes like (e.g. <image> or something else from my dtd, so i got some problems converting the string to xml. Actually i'm trying this:
         public static void setEditFragment(String content, String xPath) throws Exception {
             DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
             DocumentBuilder builder  = factory.newDocumentBuilder();
             Document document = builder.parse("data.xml");
             XPath xpath = XPathFactory.newInstance().newXPath();
             Node node = (Node)xpath.evaluate(xPath, document, XPathConstants.NODE);
             System.out.println(content);
             node.setTextContent(content);
             // Use a XSLT transformer for writing the new XML file
                Transformer transformer = TransformerFactory.newInstance().newTransformer();
                // Set output to IsoLatin1
                transformer.setOutputProperty(OutputKeys.ENCODING, "ISO-8859-1");
             DOMSource        source = new DOMSource( document );
             FileOutputStream os     = new FileOutputStream("tmp.xml");
             StreamResult     result = new StreamResult( os );
             transformer.transform( source, result ); 
         }but of course this will not work and sets up some cryptic signs in mein xml document....
    can anyone give me advice ?
    Thanks !

    Well, if you already have the data XML encoded, then just write them to a file:
    http://java.sun.com/docs/books/tutorial/essential/io/index.html
    Make sure you encode the data with UTF8:
    http://java.sun.com/javase/6/docs/api/java/lang/String.html#getBytes(java.lang.String)
    Write "<?xml version="1.0" encoding="utf-8"?>" before the data!
    Note however, I generally don't recommend to write XML data by hand. Rather use a framework like JAXB.
    -Puce
    Edited by: Puce on May 8, 2008 1:36 PM

  • String to XML conversion without fatal error?

    Can one of you tell me how to convert the folowing string to XML without fatal error?
    String s1 = "<?xml version="1.0" encoding="UTF-6.0"?> <Main> <sub> 12345 </sub> </Main>".

    First, you can't have double quotes (") in a string like that, you need to do (\") instead. If you wrote the below line and saved the file as a file_name.xml It should work fine.
    import java.io.*;
    public class yourclass{
         public static void writeXML(){
              try{
                   File xmlOut = new File("file_name.xml");
                   BufferedWriter xmlWriter = new BufferedWriter(new FileWriter(xmlOut));
                   String s1 = "<?xml version=\"1.0\" encoding=\"UTF-6.0\"?> <Main> <sub> 12345 </sub> </Main>";
                   // you can concatenate the strings using a + 
                   // the \n will create a new line in the file
                   String s2 = "<?xml version=\"1.0\" encoding=\"UTF-6.0\"?>" + "\n" +  "<Main> <sub> 12345 </sub> </Main>";
                   xmlWriter.write(s1);
                   xmlWriter.close();
              }catch(Exception ex){
                   ex.printStackTrace();
    }There are a few other ways to do this, the one above is sloppy. One is XStream to convert xml to Java objects and back again. http://xstream.codehaus.org/tutorial.html

  • Conversion of xml string to xml file

    To convert xml string to xml file in java i used
    Document XMLDoc=DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new InputSource(new StringReader("<root><main>Title</main></root&g t;")));
    But it is showing an error as InputSource cannot be resolved
    How to rectify this

    I assume you mean there is a compiler error? (It helps if you explain your problem instead of just giving a vague description of it.) It sounds like you have to import InputSource. You do know about the import statements that go at the beginning of a Java class, don't you?

  • Coversion of String to XML

    Hi,
    Is there any function or expression in BPEL/XSLT to achieve the conversion of string to xml?
    Just like the function "fn-bea:serialize() "in xquery.
    Thanks in advance,
    Rohini E

    Use :   oraext:parseEscapedXML(contentString)

Maybe you are looking for

  • External HD reformat (input/output error)

    I'm trying to reformat my external hard drive but it gives me this error everytime. I have tried reformatting it on another laptop (running snow leopard) and it still didn't work I also tried doing it while booted from CD but still didn't work.

  • How to setup E4200 as WAP only?

    I am connecting the E4200 to a Sonicwall TZ100. I want the TZ100 to assign IP addresses to devices that connect to the LAN via the E4200. How do I have the E4200 act as a WAP only or not assign IP addresses and push that responsibility to the TZ100?

  • Can a business service call a proxy service in OSB

    In Oracle service bus, can a business service call a proxy service and if yes , what is the scenario? Thanks in advance Priya

  • EXIF Info issue with Teleconverters

    Hello everybody, I think I have a problem with EXIF in Aperture (version 3.4.3) on my MacBook Pro (OS 10.8.3). For photos taken with Canon lenses plus 1.4/2.0 Canon teleconverters both Camera Info and EXIF Info are displaing all the information corre

  • Reg. ALV....pleas understand.......& have ur ponts..sure

    Hi all, I have an ALV grid with a 1st column as character type with length 20. i want to remove the redundancy of that column. Pleas see the output carefully.. wht i expect. <b>NAME          AMOUNT</b> PRADEEP       13                        12