How do i add a newline or carriage return to make my xml file look pretty?

Hi guys
I'm writing an xml file with jsp, the problem is, it writes it in one big chunk of text. e.g.
<start>hello, my name is joe</start><middle>I like trees</middle><end>boo</end>
Now what I want to do is present this xml file in a decent manner,
e.g.
<start>hello my name is joe</start>
<middle>i like trees</middle>
<end>boo</end>
i've tried
xmlFile = "<start>Hello my name is joe</start>"+\n\r;
and
xmlFile ="<start>Hello my name is joe</start>"+"\n\r";
neither work, can anyone provide me with some insight into how I can add a carriage return / new line to make my xml file look pretty?
Many thanks for any responses!

u r right <BR> tag will not work...
I wrote following code to generate xml file and it works fine...U can try the same...
try
FileOutputStream fos = new FileOutputStream("c:\\temp.xml");
String xmlString = "<root>\n<start>Hello my name is joe</start>"+"\n";
xmlString = xmlString +"<middle>blah blah</middle>\n</root>";
fos.write(xmlString.getBytes());
fos.close();
fos = null;
catch(Exception e)
e.printStackTrace();
}

Similar Messages

  • How do I add a note or highlight a word in a pdf file in iBooks?

    How do I add a note or highlight a word in a pdf file in iBooks?
    iBooks version 3.1 on iPad 4 running iOS 6.1.3.

    That functionality in iBooks is limted to ebook files and is not available for standard PDFs. Try Adobe Reader.

  • How do I add a selection screen parameter to get a application server file

    Hi All..
    Can you please suggest how can we add a selection screen parameter to get a application server file ?
    Thanx in Advance...
    Regards,
    Deepak

    <b>Parameter def :</b>
    SELECTION-SCREEN BEGIN OF LINE.
    SELECTION-SCREEN COMMENT 02(30) text-005 FOR FIELD p_xlfil.
    PARAMETERS: p_xlfil LIKE rlgrap-filename OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    <b>Browse</b>
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_xlfil.
      PERFORM ws_get_filename USING p_xlfil.
    FORM ws_get_filename USING p_xlfil.
      CALL FUNCTION 'WS_FILENAME_GET'
           EXPORTING
                def_path         = 'C:'
                mask             = ',Excel,*.xls,All,*.*.'(100)
                mode             = 'O'
                title            = 'Title'(101)
           IMPORTING
                filename         = p_xlfil
           EXCEPTIONS
                inv_winsys       = 1
                no_batch         = 2
                selection_cancel = 3
                selection_error  = 4
                OTHERS           = 5.
      IF sy-subrc NE 0.
        CLEAR p_xlfil.
      ENDIF.
    ENDFORM. " WS_GET_FILENAME
    Regards
    <b>Oops i did not read "application server"</b>
    Use FM F4_FILENAME_SERVER and not F4_FILENAME/WS_GET_FILENAME.
    Message was edited by:
            Raymond Giuseppi

  • How can I add page turn animation to my iBooks Author 2.2 file? Can I add html / a plugin?

    How can I add page turn animation to my iBooks Author 2.2 file? Can I add html / a plugin?

    I concur with Tom. That feature is not available with iBooks. If the page turning effect is important, you could consider developing a fixed layout Epub 3 instead.

  • Hello Anybody, I have a question. Can any of you please suggest me how to make an xml file from the database table with all the rows? Note:- I am having the XSD Schema file and the resulted XML file should be in that XSD format only.

    Hello Anybody, I have a question. Can any of you please suggest me how to make an xml file from the database table with all the records?
    Note:- I am having the XSD Schema file and the resulted XML file should be in that XSD format only.

    The Oracle documentation has a good overview of the options available
    Generating XML Data from the Database
    Without knowing your version, I just picked 11.2, so you made need to look for that chapter in the documentation for your version to find applicable information.
    You can also find some information in XML DB FAQ

  • How can i convert  my invoice which is in smart forms to xml file

    how can i convert  my invoice which is in smart forms to xml file.

    Hi Anil,
    Please go through this link:
    1. XSF stands for XML for Smart Forms. It is important to contrast XSF with .... The eDocx script engine can provide a script to convert the file format to an 
    http://www.ossincorp.com/Black_Box/Black_Box_4.htm
    please rewrds if found helpful.
    Regards,
    Alok

  • Carriage Returns & Line Feeds in XML documents

    Does anyone know why the PL/SQL XML parser will NOT work with Carriage Returns (0x0D) within the XML document?
    Currently I'm having to strip them out, leaving just the Line Feed (0x0A).
    I only realised this after looking at the family.xml example document.
    T.I.A.
    Geoff

    I forgot to mention that I'm running Oracle 8i on Windows NT.

  • How can I fill structure from the line with contetnt of a XML file inside?

    How can I fill structure from the line with contetnt of a XML file inside?
    I have array of lines with XML documents inside. All XML's have the same structure.
    I need to fill array of structures (with the same structure like given XML's) from data of these XML's.
    How can I do this? I am trying Transformation with ora:parseEscapedXML, but receive error: "XPath expression failed to execute.
    Error while processing xpath expression, the expression is "ora:processXSLT("Transformation_1.xsl", bpws:getVariableData("ProcessedFiles"))", the reason is javax.xml.transform.TransformerException: javax.xml.transform.TransformerException: Could not find function: parseEscapedXML.
    Please verify the xpath query."

    Ive posted the new code but now I'm getting a FileAlreadyExistException error. How do I handle this exception error correctly in my code?
    import java.io.IOException;
    import java.nio.file.FileAlreadyExistsException;
    import java.nio.file.Files;
    import java.nio.file.Paths;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    import org.xml.sax.SAXException;
    public class MyDomParser {
      public static void main(String[] args) {
      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      try {
      DocumentBuilder builder = factory.newDocumentBuilder();
      Document doc = builder.parse("ENtemplate.xml");
      doc.normalize();
      NodeList rootNodes = doc.getElementsByTagName("templates");
      Node rootNode = rootNodes.item(0);
      Element rootElement = (Element) rootNode;
      NodeList templateList = rootElement.getElementsByTagName("template");
      for(int i=0; i < templateList.getLength(); i++) {
      Node theTemplate = templateList.item(i);
      Element templateElement = (Element) theTemplate;
      System.out.println(templateElement.getAttribute("name")+ ".xml");
      for(int i=0; i < templateList.getLength(); i++) {
      Node theTemplate = templateList.item(i);
      Element templateElement = (Element) theTemplate;
      String fileName = templateElement.getAttribute("name") + ".xml";
      Files.createFile(Paths.get(fileName));
      System.out.println("File" + ":" + fileName + ".xml created");
      } catch (ParserConfigurationException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      } catch (SAXException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
      } catch (IOException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();

  • - How do you refer to an HTML carriage return in PHP?

    Someone sent me a php script that replaces foul language with
    kinder words
    in message board postings. I'd like the same script to weed
    out carriage
    returns, but we can't find the correct syntax for it.
    We're using :
    $patterns[0] = '/\n\r/';
    What's the correct syntax to use in this situation?
    Thanks!

    "David Powers" <[email protected]> wrote in message
    news:[email protected]...
    > Reese wrote:
    >> "David Powers" <[email protected]> wrote in
    message
    >>>
    >>>$patterns[0] = '/[\n\r]/';
    >>>
    >>>That searches for either a newline character or a
    carriage return.
    >>
    >> I'm told this will only work in Windows. That Macs
    would require a
    >> different string. Two, even.
    >>
    >> Anyone know if this is true?
    >
    > What you have been told is only partly correct. Windows
    uses a carriage
    > return followed by a newline character (\r\n). Macs just
    use a newline
    > character (\n).
    >
    > The pattern I have given you search for either a newline
    character or
    > carriage return. So if it's applied in such a way as to
    remove all
    > instances, it will work on both Windows and Mac. An
    alternative pattern
    > which would also work on both is this:
    >
    > $patterns[0] = '/\r?\n/';
    >
    > It looks for an optional carriage return followed by a
    newline character.
    > In other words, it still matches if there isn't a
    carriage return.
    The response of my know-it-all roumanian programmer with an
    ego the size of
    Texas to that was :
    http://www.regular-expressions.info/characters.html
    (bottom of the page)
    \r\n = windows
    \n = Linux (not Mac)
    \r = Mac
    http://www.regular-expressions.info/optional.html
    (tells you what the '?'
    does)
    (it means that the character before it can be there 0 or 1
    times)
    \r?\n = \n (Linux) or \r\n (windows)
    It leaves out the \r all alone, like added by the Mac.
    So, it will not delete the Mac new lines (might delete the
    Mac OSX ones
    since that one is passed on Linux, but not the older ones.)
    Now, you can contradict me all you want and have a busted
    code (then you
    will say it doesn't work because I made it wrong), or do it
    like I told you
    and get it working like it should.
    To this, I told him I would present this to you for a
    rebuttal, but not
    before asking him why he used only the '/\r?\n/' model as an
    example, and
    not the recommended '/[\n\r]/'. Something tells me he has no
    idea what [
    and ] do in this context, so he's avoiding it altogether --
    even though it
    may very well solve the problem on its own the way you claim
    it does.

  • How to add users/entry in the oracle internet directory using XML file

    hi friends,
    i need to know how to add entries, attributes in the oracle internet directory using the XML file.

    I could able to execute the ldapadd command with out error as
    ldapadd -h islch-532.i-flex.com -p 389 -D "cn=orcladmin" -w password -X mypath/filename.xml
    but the data entry is not added in OID. can any one help me out.

  • How can i add more than one portlet description in my provider.xml

    I already tested MyFirstPortlet developed using JPDK and is working fine.I add one more portlet description in the same provider.xml. But the new portlet is not getting displayed under the provider when i try to add it in my page.
    null

    Abdulla,
    I just want to verify that I understand your question. You successfully created "MyFirstPortlet" using the JPDK, now you are trying to add a second portlet using the provider.xml file and it does not show up in the Add Portlets Screen when trying to add the new portlet to a page.
    This could be one of many different problems.
    1) Make sure that you added it to the provider.xml file correctly. You should have two portlets within one provider within the file. For example (note only displaying tags, content missing):
    <provider class="oracle.portal.provider.v1.http.DefaultProvider" session="true">
    <portlet class="oracle.portal.provider.v1.http.DefaultPortlet" version="1" >
    <id>1</id>
    </porltet>
    <portlet class="oracle.portal.provider.v1.http.DefaultPortlet" version="1" >
    <id>2</id>
    </porltet>
    </provider>
    Notice above that i have two portlet open/close tags within a single provider.
    2) Make sure that the location of this file is the one listed in zone.properties.
    3) Make sure you stop and restart your listener to accept the changes of the provider.xml file.
    4) Login to Portal as an Administrator and go to the Administration page of Portal. Click on Administer, then click on "Display Portlet Repository". Click on Refresh at the top right of the page to retrieve the changes to the provider.xml file. Scroll down to the myfirstprovider and you should now see the new portlet you added.
    Hope this helps,
    Sue

  • Carriage Returns and Tabs in XML element

    I have a number of carriage returns and tabs within an xml element. When I take that element I would like it to transform to html in which I am then displaying within a JEditorPane. However, when I do this it is one long string. I have tried the xml:space="preserve" within that element and this still is not working.
    Here is part of the xml with the carriage return line feeds. The element that I am talking about is called pseudocode. You can see it is displayed correctly below.
    Design Document XML : <?xml version="1.0" encoding="ISO-8859-1"?><design-doc><title-page><title>Testing Document</title><class-prepared-for>Lloyd</class-prepared-for><authors>Ben Garbers</authors><date-created>September 23, 2004</date-created></title-page><introduction text="This is the introduction. This is the introduction."/><class-definitions><class-definition class-name="ClassOne" visibility="public" class-complexity="not complex"><global-variables><variable visibility="public" name="VariableOne" object="String" comments="This is a String."/><variable visibility="public" name="VariableTwo" object="Integer" comments="This is an Integer."/></global-variables><methods><method name="MethodOne" synopsis="This will do some things." purpose="public" visibility="public"><input-parms><variable visibility="null" name="firstName" object="String" comments="null"/></input-parms><output-parms><variable visibility="null" name="lastName" object="String" comments="null"/></output-parms><local-variables><variable visibility="null" name="age" object="int" comments="null"/></local-variables><pseudocode xml:space="preserve">/* Ensure that player name exist in the system*/
    if (player =null)
         NullPlayerException;
              if (NOT (isPlayerNameExist(player)))
                   throw PlayerNameNotExistException;
              /* Ensure player name exist in the team already*/
              i ? 1;
              while (i <= length(mPlayers)) {
                   if (mPlayers.mPlayerName != playerName)
                        throw PlayerNameNotExistInTeamException;
    this.mPlayers ? this.mPlayers - player;</pseudocode>
    However, when I do the transformation I get the following with the pseudocode:
    /* Ensure that player name exist in the system*/if (player =null)     NullPlayerException;          if (NOT (isPlayerNameExist(player)))               throw PlayerNameNotExistException;          /* Ensure player name exist in the team already*/          i ? 1;          while (i <= length(mPlayers)) {               if (mPlayers[i].mPlayerName != playerName)                    throw PlayerNameNotExistInTeamException;}this.mPlayers ? this.mPlayers - player;
    It looks like it adds some spaces but no carriage returns or line feeds.
    My transformation code is the following:
         public ParseFile(String xmlString) {
              try {
              //Here we will load the correct style sheet for the message
              //that will be formatted.
              String urlString = "DesignDocument.xsl";
              URL url = this.getClass().getResource(urlString);
              System.out.println("URL to style sheet = " + url.toString());
              String styleSheetName = url.getFile();
              System.out.println("Style sheet name : " + styleSheetName);
              InputStream styleSheetInputStream = this.getClass().getResourceAsStream(urlString);
              //We will than load our SAXParerFactory and parse the message.
              SAXParserFactory SPFactory = SAXParserFactory.newInstance();
              SPFactory.setValidating(true);
              SAXParser sp = SPFactory.newSAXParser();
              XMLReader sax2parser = sp.getXMLReader();
              //NO Validation done on for this because we do NOT have a DTD.
              sax2parser.setFeature(
                   "http://xml.org/sax/features/validation",
                   false);
              sax2parser.setContentHandler(new FileContentHandler());
              //we create a character array of the length of the xml message String
              char[] messageCharacterArray =
                   new char[xmlString.length()];
              // we then put the xml string into the character array.
              messageCharacterArray = xmlString.toCharArray();
              // after this ew end up creating a CharArrayReader that will be used by the Sax
              // parser to parse the xml.
              CharArrayReader xmlCharArrayReader =
                   new CharArrayReader(messageCharacterArray);
              // we put the xml character array within the Input Source which will then be parsed
              // by the Sax2 parser.
              InputSource in = new InputSource(xmlCharArrayReader);
              // Use a Transformer for outputting the message into our formatted xml using
              // the stylesheet defined up in a messages own sxl stylesheet file.
              TransformerFactory tFactory = TransformerFactory.newInstance();
              tFactory.setURIResolver(new BasicURIResolver());
              StreamSource stylesource = new StreamSource(styleSheetInputStream);
              Transformer transformer = tFactory.newTransformer(stylesource);
    //          transformer.setOutputProperty(OutputKeys.INDENT, "yes");
    //          transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
    //          Properties properties = new Properties();
    //          properties.setProperty("indent", "yes");
    //          properties.setProperty("{http://xml.apache.org/xslt}indent-amount", "2");
    //          transformer.setOutputProperties(properties);
              // We will use a ByteArrayOutputStream to put our transformed xml.
              ByteArrayOutputStream bos = new ByteArrayOutputStream();
              StreamResult result = new StreamResult(bos);
              SAXSource source = new SAXSource(in);
              transformer.transform(source, result);
              String s = bos.toString();
              StringBuffer sb = new StringBuffer();
              //This will make sure the Version Line is not shown.
              BufferedReader br = new BufferedReader(new StringReader(s));
              String line = "";
              while ((line = br.readLine()) != null) {
                        sb.append(line);
              bos.close();
              br.close();
              formattedXmlString = sb.toString();
              System.out.println("--------------------------------");
              System.out.println(formattedXmlString);
              System.out.println("--------------------------------");
              } catch (Exception e) {
                   e.printStackTrace();
    I have been searching and trying to figure this out forever. Any help would be greatly appreciated. Bottom line is that I want carriage returns and tabs to work when transferring from the xml to xsl.

    I get the following line when adding the <pre> tags.
    /* Ensure that player name exist in the system*/if (player =null)     NullPlayerException;          if (NOT (isPlayerNameExist(player)))               throw PlayerNameNotExistException;          /* Ensure player name exist in the team already*/          i ? 1;          while (i <= length(mPlayers)) {               if (mPlayers[i].mPlayerName != playerName)                    throw PlayerNameNotExistInTeamException;}this.mPlayers ? this.mPlayers - player;
    On the screen this is shown on 1 line. It looks like the tabs are working correctly. However, the carriage return, line feeds do not seem to be working. The xml that is pushed into the transformation has the carriage returns and line feeds and is formatted correctly. There has to be something happening when the xsl takes the xml String. When I add <BR></BR> within the xml that doesn't seem to work either.
    I am really sumpted. If you could help DrClap I would really be appreciated.

  • Load xml to Datagrid, add row or edit and save it to the xml file??

    Good afternoon,
    I know how to load the xml, add a row or edit the data in a datagrid . Only thing I dont't  know
    how to save the changes to the xml file. I'm ussing Flash Professional CC and it wil be an Adobe Air
    desktop application.

    Hi, and thank for the reply. Problem is not saving the xml, but getting the edited or new rows in the datagrid  to be saved in the xml.....

  • Hard Carriage Returns on Paragraph and XML

    Hi,
    I'm still running FM 7.2, I have 8.0, but we are not ready as a company to move yet.
    I am capturing legacy FM information and need to save as XML.
    This information will at times have paragraphs that used hard carriage returns to build in separation and make things easier to read.
    When we export this XML, these hard CRs are removed and all extra white space is compressed out of the element.
    This is causing much grief for the people reading the documents and they have asked if I can retain the hard breaks.
    I've looked into the Structured Application and found nothing. I've looked at the ReadWrite Rules files in hopes I could map the hard break to a element of some kind, or something like that. I'm not finding any solutions.
    Is there a way to keep this information in the resulting XML file?
    Thanks,
    - mike

    Hello Mr. Hare,
    you might try the following:
    1. Adjust the template of your structapp to contain a variable named "hardreturn" whose definition is "\n" (without the quotiation marks).
    2. In your R/W-Rules, write: entity "hardreturn"is fm char 0x09;
    3. In every FM-Document you want to save as XML
    a. also add the variable
    b. assign the structapp
    4. ..and do the following
    a. insert the variable "hardreturn" somewhere and copy it into the clipboard, and delete the variable from your insertion point
    b. Search for "\p\p" (=two consecutive hard returns, i.e. an "empty line" or for "\x09" (= a soft return) and "change" "by pasting".
    The result should be a variable "hardreturn, wherever \p\p or \x09 was.
    If you save this as XML, the \x09 from the variable should survive as an entity.
    Hope this helps.
    With kind regards,
    Franz.
    [ excess signature removed by host ]

  • How to specify the webLogic server startup script to use different config.xml  file ??

    Hi,
    I have 2 weblogic startup scripts (startWebLogic.sh and
    startWebLogic_recovery.sh) for the same domain.
    startWebLogic.sh uses config.xml file.
    I would like to use config_recovery.xml as the configuration file for startWebLogic_recovery.sh
    How would I do this ?
    I am using WebLogic Server 6.1 on SunOS 5.8 / HP-UX 11.0.
    Appreciate any help.
    Regards
    Gunaseelan Venkateswaran

    I guess you're using Weblogic 6.1 with WLCS 3.5. I think you're supposed to work with one config.xml for the same domain, and not have a different config.xml.
    To start up different applications or EJBs, use the "target" property to control which applications to start up for the particular instance.
    YY

Maybe you are looking for

  • Addition of 0MAT_PLANT  to a cube

    Hi, I have the following requirement. I need to create a report on a cube where I need to display a field called Import Code of a material This Characteristic is an attribute of 0MAT_PLANT InfoObject. The cube has 0MATERIAL and 0PLANT. But it does no

  • Standrad smartform and standard print program not available in ECC 6.0

    Hi gurus, I have a requirement like, I need to change the logo of the standrad smartform based on the company code. The standard smartform name is '/SMBUSE/US_MMGR3'. I have searched for the above form in ECC 6.0 and could not find one. is the issue

  • Portal theme not picked for SAP Web Dynpro Iview

    Hi, We have used light framework page for our portal and all the iviews display the content within the iviews in the same set of colors (blue for buttons). However, for a WD java content, I have created an SAP Web Dynpro iView and the contents displa

  • ALSB 2.6 Dynamic Schema Validation

    ALSB 2.6 has a validation stage (Schema or WSDL), but requires a type to be selected during development. It would be nice if a WSDL based proxy could recognize the correct input message on an operational branch and dynamically choose the correct vali

  • How do i restore deleted videos, how do i restore deleted videos?

    I dont know how to restore a video that i have deleted can any one help me ?