How to scape chars for XML?

Hi!,
I am generating a XML file.
Would you please help about escaping the text nodes ?
The following code produces an invalid XML file for having the "?" on the text node.
Thansk in advance!
import javax.xml.parsers.*;
import org.w3c.dom.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import javax.xml.transform.stream.*;
public void writeXML(OutputStream os)
Document docXML;
Element root;
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
docFactory.setValidating(true);
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
docXML = docBuilder.newDocument();
root = docXML.createElement("ROOT");
root.appendChild( docXML.createText("Text?"));
docXML.appendChild(root);
docXML.normalize();
Transformer transformer = TransformerFactory.newInstance().newTransformer();
transformer.transform(new DOMSource(docXML), new StreamResult(new OutputStreamWriter(os)));

Thanks.
I am sorry!
The java code was escaping correctly characters but the enconding at the top of the generated XML file was wrong, it generates
<?xml version="1.0" encoding="UTF-8" ?>
and I require for having european characters
<?xml version="1.0" encoding="ISO-8859-1" ?>
How should I change the econding for the generated XML file?

Similar Messages

  • How to write POJO for XML file.. i do not want to use JAXB or any other tec

    How to generate POJOs for the specific xml files.
    Each XML file will have elements name with Type. Which in turn related to some other xml file
    For example
    student.xml
    <student name"mystudent">
    <studentname type="firstname"/>
    <studentname type="firstname"/>
    <studentname type="firstname"/>
    </student>
    firstname.xml
    <studentname name="firstname">
    <stufirstname type="myfirstname"/>
    </studentname>
    myfirstname.xml
    <myfirstname name="myfirstname">
    <myname1>xxx</myname1>
    </myfirstname>
    like this there will be so many xml files interlinked.
    I would like to write POJOs for these xml files
    please let me know what is the best way to write (design the hirarchy of these xml files
    Thanks in advance
    srinivas

    Not at this time. You may submit your polite feedback to Apple using this webpage: http://www.apple.com/feedback/itunesapp.html

  • How to read char() for bit data DB2's type in Oracle?

    Hello,
    I am developing an application (from JDeveloper) to operate with two data base. In one hand threre is Oracle and in the other one DB2 (AS400).
    I am trying to read a DB2'sfield with the "char() for bit data" type from Oracle, but I can't read it.
    I have trying:
    rset.getObject(1) -->[B@1a786c3
    rset.getBinaryStream(1) --> java.io.ByteArrayInputStream@1a786c3
    rset.getAsciiStream(1) --> java.io.ByteArrayInputStream@2bb514
    rset.getCharacterStream(1) -->java.io.StringReader@1a786c3
    Do you have any solution to see the value of this type of field?
    Thank you and regards

    I have to synchronize unidirectionally from the Oracle database to DB2. And I'd like to save the information of the record of DB2 prior to the update operation.
    And here is where the problem arises for me, because when I try to read from Java with the connection established on DB2 is unable to interpret the information. While there are no problems from Oracle to consume the information, it happens that DB2 field types are not common with Oracle, such as char () for bit data. From what I could find the equivalent in Oracle would be raw (), but since Java is possible to read this type of information... And this is my doubt, it is necessary to do any type of cast or to do a special view to retrieve this information?

  • How to set encoding for xml Marshaller?

    Hi,
    I am using SAPXMLToolkit. And I use XMLMarshaller to convert from xml to java classes (jaxb classes). Now when I get some characters like ü, the marshaller gives an error
    com.sap.engine.lib.xml.parser.ParserException: Unsupported character: 69(:main:, row:1, col:323)
         at com.sap.engine.lib.xml.parser.readers.EncodedDataReader.read(EncodedDataReader.java:207)
         at com.sap.engine.lib.xml.parser.readers.EncodedDataReader.read(EncodedDataReader.java:205)
         at com.sap.engine.lib.xml.parser.helpers.AdvancedXMLStreamReader.read(AdvancedXMLStreamReader.java:152)
         at com.sap.engine.lib.xml.parser.XMLParser.scanCharData(XMLParser.java:1896)
         at com.sap.engine.lib.xml.parser.tokenizer.XMLTokenReaderImpl.next(XMLTokenReaderImpl.java:190)
    How do I solve this?? How do I set encoding for the marshaller?
    Regards,
    Guru

    Hi ogre,
    To set the encoding scheme for an XML document, you can use the createProcessingInstruction. Our CVIXML instrument driver (which
    is basically and user-friendly wrapper made around the MSXML interface) uses
    this method to specify the version of the XML document. So, what you could do
    is simply modify our existing CVIXML instrument driver to include the encoding.
    It's actually quite simple to do this.
    First off, open up the cvixml.c file
    located in the <CVI>\toolslib\toolbox directory in CVI. Then change the
    value of the constant XML_PROC_INSTR_DATA
    (located on line 42) from "version=\"1.0\"" to "version=\"1.0\"
    encoding=\"UTF-8\"". The save your source file and
    select Options >> Create Object file. This object file
    (cvixml.obj) is attached to your cvixml.fp function panel. 
    To test this out, you could simply use some code like
    CVIXMLNewDocument ("RootElement", &xmlDoc);
    CVIXMLSaveDocument (xmlDoc, 0, "C:\\Test.xml");
    Then the Test.xml document should say
    <?xml version="1.0" encoding="UTF-8"?>
    <RootElement/>
    Hope this helps!
    Best Regards,
    Jonathan N.
    National Instruments

  • How to create table for XML schema-based Interface form

    Hi All,
    With tcode SFP to crate  a XML schema-based Interface form, how to create a defined table can be listed in "Data View"?
    Just like APAP Dictonary- Based Interface form, that we can drag  a defined table from data view to the panel.

    Hi,
    Just follow these steps:
    1. Create interactive form UI element in your view.
    2. Now provide Datasource and PDFSOURCE to it in form properties.
    3. Now give a template name prefix with 'Z' or 'Y'.
    4. Double click on it. It will prompt for interface name.
    5. Provide interface name prefixed with 'Z' or 'Y'.
    6. Click on Context button in the Pop up window and provide the node you have selected as DATASOURCE.
    7. Click ok and it will open the form designer.
    8. In this way you can create a XML Schema based Form.
    9. Activate the interface and design the form providing layout type and other details.
    Hope it will help.
    Regards,
    Vaibhav

  • How to clear cache for XML data source?

    Hi All,
    I'm facing a problem loading XML data into Oracle using Oracle Data Integrator. The problem is ODI will cache the data of the XML file at the first time loading the data. And afterwards, when the XML file changed, ODI will load data from the cache.
    I did serveral testing on this. If I run the interface in local agent of the designer, I must restart the designer to clear the cache. If I run the interface in an agent, I must restart the agent to clear the cache.
    Below is my configuration:
    ODI version: 10.1.3.5.0
    The technology of the source: XML.
    JDBC driver: com.sunopsis.jdbc.driver.xml.SnpsXmlDriver
    Does anybody know how to clear the cache of the agent or XML?
    Thanks.

    Hi ,
    Use drop_on_disc or dod in your JDBC URL .
    example ,
    jdbc:snps:xml?f=C:\mutation.xml&d=C:\mutation.xsd&lf=C:\mutation.log&ro=true&dod=yes
    The dod (drop_on_disc) drop automatically the schema when closing the JDBC connection.
    dod option must be the last option of the URL.
    This option removes the reference to the schema from the driver, and if the schema is store in memory, it also drops the schema. If the schema is stored in an external database (set via db_props), the driver tries to drop the database schema.
    Thanks,
    Sutirtha

  • Help required - How to flush memory for XML files ?

    Hi,
    I am receiving files with filenames like FILE_001.xml, FILE_002.xml, etc. all with the same XML format.
    I need to process each file by order of their filename and load them into the same table.
    I created a loop that renames each file to a standard filename, FILE.xml , and load into the table.
    However, when I process the 2nd file ie. FILE_002.XML to FILE.xml, the data in FILE_001.xml is loaded again. The data in FILE_001.XML still exists in memory.
    Need your advice how to get pass this problem.
    Thanks.
    Philip

    Hi Philip,
    You can use a TRUNCATE SCHEMA command on the XML Logical schema to remove the content previously loaded and then a SYNCHRONIZE FROM FILE to load the content of the new file in the backend. Refer to the XML Driver documentation in the ODI Documentation Library (Detailed Drivers Command).
    These commands should be included in an ODI procedure that you can use in your loop.
    Thanks,
    Julien

  • How to extract data from XML file with JavaScript

    HI All
    I am new to this group.
    Can anybody help me regarding XML.
    I want to know How to extract data from XML file with JavaScript.
    And also how to use API for XML
    regards
    Nagaraju

    This is a Java forum.
    JavaScript is something entirely different than Java, even though the names are similar.
    Try another website with forums about JavaScript.
    For example here: http://www.webdeveloper.com/forum/forumdisplay.php?s=&forumid=3

  • How-to use Excel for the XML file input?

    Hello all,
    Following our discussion with Gerhard Steinhuber on the very nice tutorial from Horst Schaude , "How to upload mass data via XML File Input" , I am starting this new discussion.
    In the comments section of this previous cited tutorial, Rufat Gadirov explains how to use a generated XML from Eclipse instead of your XSD file as your source in Excel.
    However, in spite of all the instructions, I am still facing the same issue in Excel when I try to save my file as XML : "The XML maps in this workbook are not exportable".
    What I try to do is to create one or more Sales Orders with multiple Items in it from a XML File Input, using excel to enter data.
    The part with the File input is working (if I directly upload my file to the webDAV, it creates a sales order instance with multiple items).
    The only missing part is the Excel data input that I cannot make work. Any help on this matter would be greatly appreciated.
    Here is my XML file that I try to use as a source in Excel before inputing data from Excel:
    <?xml version="1.0" encoding="UTF-8"?>
    <p:MySalesOrderUploadedIntegrationInputRequest xmlns:p="http://001365xxx-one-off.sap.com/YUUD0G3OY_" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <MessageHeader>
        <CreationDateTime>2015-03-02T12:00:00.000Z</CreationDateTime>
    </MessageHeader>
        <List actionCode="01" listCompleteTransmissionIndicator="true" reconciliationPeriodCounterValue="0">
            <MySalesOrderUploaded>
              <MySalesOrderUploadedID>idvalue0</MySalesOrderUploadedID>
              <MyBuyerID schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeID="token">token</MyBuyerID>
              <MyDateTime>2015-03-02T12:00:00.000Z</MyDateTime>
              <MyName languageCode="EN">MyName</MyName>
              <MyBillToParty schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MyBillToParty>
              <MyDateToBeDelivered>2001-01-01</MyDateToBeDelivered>
              <MyEmployeeResponsible schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MyEmployeeResponsible>
              <MySalesUnit schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MySalesUnit>
                <MyItem>
                    <MyItemID>token</MyItemID>
                    <MyItemProductID schemeAgencyID="token" schemeID="token">token</MyItemProductID>
                    <MyItemDescription languageCode="EN">MyItemDescription</MyItemDescription>
                    <MyProductTypeCode>token</MyProductTypeCode>
                    <MyRequestedQuantity unitCode="token">0.0</MyRequestedQuantity>
                    <MyConfirmedQuantity unitCode="token">0.0</MyConfirmedQuantity>
                    <MyNetAmount currencyCode="token">0.0</MyNetAmount>
                </MyItem>
            </MySalesOrderUploaded>
            <MySalesOrderUploaded>
              <MySalesOrderUploadedID>idvalue0</MySalesOrderUploadedID>
              <MyBuyerID schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeID="token">token</MyBuyerID>
              <MyDateTime>2015-03-02T12:00:00.000Z</MyDateTime>
              <MyName languageCode="EN">MyName</MyName>
              <MyBillToParty schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MyBillToParty>
              <MyDateToBeDelivered>2001-01-01</MyDateToBeDelivered>
              <MyEmployeeResponsible schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MyEmployeeResponsible>
              <MySalesUnit schemeAgencyID="token" schemeAgencySchemeAgencyID="1" schemeAgencySchemeID="token" schemeID="token">token</MySalesUnit>
                <MyItem>
                    <MyItemID>token</MyItemID>
                    <MyItemProductID schemeAgencyID="token" schemeID="token">token</MyItemProductID>
                    <MyItemDescription languageCode="EN">MyItemDescription</MyItemDescription>
                    <MyProductTypeCode>token</MyProductTypeCode>
                    <MyRequestedQuantity unitCode="token">0.0</MyRequestedQuantity>
                    <MyConfirmedQuantity unitCode="token">0.0</MyConfirmedQuantity>
                    <MyNetAmount currencyCode="token">0.0</MyNetAmount>
                </MyItem>
            </MySalesOrderUploaded>
        </List>
    </p:MySalesOrderUploadedIntegrationInputRequest>
    Thank you all for your attention.
    Best regards.
    Jacques-Antoine Ollier

    Hello Jacques-Antoine,
    I suppose that as you have tried to construct a map from the schema, you have taken the elements from the List level down. In this case I also can't export the map.
    But if you take the elements from the level MySalesOrderUploaded down, you'll get the exportable map (screenshots)
    Best regards,
    Leonid Granatstein

  • How can I check for the existence of an XML file in Illustrator Javascript??

    I'm writing a Javascript to run at startup. I want to check for the existence of XML files and process them, if they are available. How can I check for their existence?

    Your first line just sets a variable to a string value… getFiles() is a method of Folder… so
    var InputXMLDir = Folder( "D:/Brackets/Create_Bracket_Graphics/Input/XML-n-Templates/" );
    Not a PC user so I can't remember if the colon is OK…? As you appear to know the file name why bother with a folder get files anyhow you could just check if the file exists then do some thing…
    alert( File( "D:/Brackets/Create_Bracket_Graphics/Input/XML-n-Templates/brackets_men_web.xml" ).exists );

  • How do you get an xml file from the PO Output for Communication report?

    Can anyone tell me how you've created an xml output fil for this program? When I run it, the View XML button doesn't light up, and the output file is empty.
    I can see the XML when I click the View Log button, but can't figure out how to save it so that the XMLP Desktop tool can load it properly.
    If you can tell me how to create this file, I'd be very appreciative.

    Hi,
    I can't see the xml in my log file. Maybe you have a different logging level. One issue I have had before is that the xml declaration had a strange character encoding. It should say something like: <?xml version="1.0" ?>. If it mentions anything about encoding you can remove it.
    One of our developers wrote a custom process to write the xml to a table when the document was generated as we couldn't find any other way of doing it.
    You can use the sample xml available from the data definition but this is missing fields.
    Probably not much help...
    Paul

  • How to change a rss.xml file for m3u file for my podcast

    Bonjour,
    I actually produce as well a podcast with unless 3 mp3 file,and that's ok ... But, on one of my post, I stream a playlist to a page of my website , and I noticed, after generating a playlist from my player when streaming (.m3u file)... I notice that I can play it in i tunes in a continuing stream (I can connect from this file in itunes on another post to my stream (note that I use a static IP from my access provider, in order to a stable connection to my web site - without using No IP) ...
    My question is,as the application recognizing the file and playing it,how to configure my rss.xml for this type of file(*.m3u)...
    Thank you for replying

    I don't think you are going to be able to do this: podcasts are not intended to contain streams or playlists, only specific audio or video files. The fact that the iTunes Application can connect to it doesn't mean that it will work in a podcast feed. However if you want to ask iTunes Support for advice it's at at
    http://www.apple.com/support/itunes/ - click on 'Other iTunes Store Features' in the list and then on 'Podcasts'.

  • How to change UTF-8 encoding for XML parser (PL/SQL) ?

    Hello,
    I'm trying to parse xml file stored in CLOB.
    p := xmlparser.newParser;
    xmlparser.parseCLOB(p, CLOB_xmlBody);
    Standard PL/SQL parser encoding is UTF-8. But my xml CLOB contain ISO-8859-2 characters.
    Can you advise me, please, how to change encoding for parser?
    Any help would be appreciated.
    null

    Do you documents contain an XML Declaration like this at the top?
    <?xml version="1.0" encoding="ISO-8859-2"?>
    If not, then they need to. The XML 1.0 specification says that if an XML declaration is not present, the processor must default to assume its in UTF-8 encoding.

  • How can I define an XML schema for this kind of XML

    Hi, There:
    I want to generate an XML file like:
    <customer>
    </customer>
    <transaction>
    </transaction>
    <customer>
    </customer>
    which have multiple customer elements and multiple transactions as well, and they can happen in mixed sequence. Can any one give me some idea about how can I create an XML schema for this kind of xml? (<xsd:complextype> <xsd:sequence> ) seems not work)
    Thanks in advance
    David

    Use a group then make it a choice, like this;
    <xs:element name="Parent">
    <xs:complexType>
    <xs:group ref="Group" minOccurs="1" maxOccurs="unbounded" />
    </xs:complexType>
    </xs:element>
    <xs:group name="Group">
    <xs:choice>
    <xs:element ref="OptionOne" type="xs:string" />
    <xs:element ref="OptionTwo" />
    </xs:choice>
    </xs:group>
    <xs:element name="OptionOne">
    <xs:complexType>
    <xs:attribute name="name" type="xs:string" />
    <xs:attribute name="Type" type="xs:string" />
    </xs:complexType>
    </xs:element>
    <xs:element name="OptionTwo">
    <xs:complexType>
    <xs:attribute name="name" type="xs:string" />
    <xs:attribute name="Type" type="xs:string" />
    </xs:complexType>
    </xs:element>
    This allows XML like this
    <Parent>
    <OptionTwo ........ />
    <OptionOne ........ />
    <OptionTwo ........ />
    <OptionOne ........ />
    <OptionOne ........ />
    </Parent>
    HH

  • How to setup Check Writer (XML) for Canada?

    I need to set up Check Writer (XML) for Canada. On MOS Note 459306.1 it appears that this is for US legislation. Has anyone successfully set this up for Canada, and if so, how?
    Thanks...Paul

    Please see (Cannot Find Documentation On Configuring Canada Check And Deposit Advice For XML [ID 557717.1]).
    Thanks,
    Hussein

Maybe you are looking for

  • Delete the parent records and child table records at a time

    hi all; I am facing the pbm like to delete the all records in child table and corresponding records in parent table at a time. so I want to delete the all the records in child table and corresponding parent records in parent table by using single SQL

  • Magnifying help

    Hi I am doing a multi course but cant seem to get this to work i was wondering if anyone can help ill post the instructions i was given and if anyone can help id greatly appreciate it Step one: Creating the image you want to magnify Before you can st

  • How do i find out the password to do my backup to complete the iOS5 update?

    what do I do since i forgot the password to restore my phone from its last backup?

  • Error -45054 fixed ? Apple help

    Hi it seems to have some people with the same issue Please do the HelpDesk & Customer service could help to fix this issue ! Music is off Synch with mobiles off iTunes not running on Maverick the issue is coming after a popup informing not enough rig

  • Changing Database

    I built a report using a MYOB ODBC connection for one MYOB company.  I'm trying to use the same report but on a different MYOB company file.  I've got my two ODBC connections set up but when I update the database connection to the 2nd MYOB connection