DOMParser.parse question

Hi all,
I have parsed an XML document resulting in a DOM. Then I am going through and returning a nodeList by:
dSLDocument.getElementsByTagName("PurchaseOrder");This returns the tag that I am after but what I need to do is then create a new DOM from this element and its subElements.
Is this possible? I tried parsing the NodeList.item[0] but this is not a valid param to the method....
Any help much appreciated,

Hi and thanks for the reply - Ive looked everywhere,
This seems to be changing the structure of the XML document but instead of appending the fragment that I am after its removing that specific part and leaving what I dont want in the new Document....So I am left with a new Document which has none of the elements that I am after,
Do you know what is going on here?
Thanks again,

Similar Messages

  • ArrayIndexOutOfBoundsException during DOMParser.parse(...) operation

    Please provide assistance with clarifying any limitations of the DOMParser.parse() operations. Please let me know if there is an alternative approach to what I am doing below. The details of my situation follow:
    I am using Visual Cafe 3 with the Oracle XML parser 2.0.2.6 to parse an XML string using the DOMParser parse(Reader), parse(InputSource), parse(InputStream) operation in order to retrieve a DOMDocument object.
    I have taken several approaches all of which result in the following exception:
    "java.lang.ArrayIndexOutOfBoundsException: 16388"
    This error appears to be raised by XMLReader:
    oracle\xml\parser\v2\XMLReader(1411)... The java source is unavailable to debug the code.
    I have also changed the XML string to a simple innocuous string. But I still get the same message. The literal string value is as follows: "<?xml version="1.0"?><EMPLIST><EMP><ENAME>MARTIN</ENAME></EMP><EMP><ENAME>SCOTT</ENAME></EMP></EMPLIST>"
    The code fragments I have used to perform the parse() operations are given below:
    //Reader approach
    StringReader xmlReader = new StringReader( inXMLString );
    parser.parse( xmlReader );
    // InputSource approach
    InputSource source = new InputSource( xmlReader );
    parser.parse( source );
    // InputStream approach
    ByteArrayInputStream byteStream = new ByteArrayInputStream( inXMLString.getBytes() );
    parser.parse( byteStream );
    Any assistance would be greatly appreciated.
    null

    Please provide assistance with clarifying any limitations of the DOMParser.parse() operations. Please let me know if there is an alternative approach to what I am doing below. The details of my situation follow:
    I am using Visual Cafe 3 with the Oracle XML parser 2.0.2.6 to parse an XML string using the DOMParser parse(Reader), parse(InputSource), parse(InputStream) operation in order to retrieve a DOMDocument object.
    I have taken several approaches all of which result in the following exception:
    "java.lang.ArrayIndexOutOfBoundsException: 16388"
    This error appears to be raised by XMLReader:
    oracle\xml\parser\v2\XMLReader(1411)... The java source is unavailable to debug the code.
    I have also changed the XML string to a simple innocuous string. But I still get the same message. The literal string value is as follows: "<?xml version="1.0"?><EMPLIST><EMP><ENAME>MARTIN</ENAME></EMP><EMP><ENAME>SCOTT</ENAME></EMP></EMPLIST>"
    The code fragments I have used to perform the parse() operations are given below:
    //Reader approach
    StringReader xmlReader = new StringReader( inXMLString );
    parser.parse( xmlReader );
    // InputSource approach
    InputSource source = new InputSource( xmlReader );
    parser.parse( source );
    // InputStream approach
    ByteArrayInputStream byteStream = new ByteArrayInputStream( inXMLString.getBytes() );
    parser.parse( byteStream );
    Any assistance would be greatly appreciated.
    null

  • DOMParser.parse(URL) hangs

    Anytime I call DOMParser.parse(URL) where URL is of type "http://", the parse call hangs (as near as I can tell) indefinitely. Are URLs of this type not supported? Is there a work around to this problem?

    No. Within the same class, the following DOES work:
    DOMParser dp = new DOMParser();
    dp.setErrorStream(new PrintWriter(errs));
    // Set Schema Object for Validation
    dp.setXMLSchema((XMLSchema)((new XSDBuilder()).build(schema.location)));
    Note that schema.location is a String like "http://www.wherever.com/file.xsd" which points to the web server that is hanging on DOMParser.parse(URL);

  • DOMParser parse & namespaces

    I've notice that when I parse a stream using (java) DOMparser.parse, where that steam contains namespace prefixes, the parser returns with errors even though I've set the validationmode to false. Is this intended behavior, and if so how do I circumvente the parser from trying to resolve namespaces, but just check wellformedness?

    You can't turn off the parser's namespace support. If you have invalid namespace prefixes, then an XML 1.0 Parser with XML Namespaces support (which ours is) should raise an error.
    Resolving namespace prefixes is not part of validation, it's part of wellformedness checking.

  • Error message when using DOMParser.parse(file)

    When I try to use the DOMParser.parse(file) to parse an invalid XML file against a XML schema, with the schema_validation feature set on, error message saying the XML file is invalid because it violates some constraints set in the schema. But I cannot find out how the error message is print. It is not caught as exception. May I know how can I detect the error in the code instead of viewing it as output?

    The error message I got is like the followings:
    [Error] abc3.xml:2:310: cvc-pattern-valid: Value '' is not facet-valid with respect to pattern '(\(\d\d\d\)-)?[\d]{8}' for type 'phoneNoType'.
    [Error] abc3.xml:2:310: cvc-type.3.1.3: The value '' of element 'mobile' is not valid.
    [Error] abc3.xml:2:318: cvc-pattern-valid: Value '' is not facet-valid with respect to pattern '[^@]+@[^\.]+\..+' for type 'emailAddressType'.
    [Error] abc3.xml:2:318: cvc-type.3.1.3: The value '' of element 'email' is not v
    alid.
    May I know how can I catch these errors?

  • Tough Parsing question???

    Please try to help me with the following parsing question.
         I have an exert from the 2000 Tiger/Line Census files that looks
         something like this:
         0001     A     Libby     Ln     -92.99999+25.87787      -92.87679+26.65543
         0002     A     Capri     Ave     -93.32343+23.3332 3      -24.34444+34.22222
         0003     A     Minster Grove Ln     -93.23433+22.2223432     -98.343343+23.34332
         0003     A     Houston Ave -91.99892+22.323322     -98.434543+33.33233
         0004 A I-10          Int -91.23234+32.343232     -97.333233+34.22222
         0005 C     Trenton Springs Ct. -90.22232+33.222123          -91.234432+23.33221
         I want to parse it so I can enter it into an SQL database.
         Normally this would be an easy task but, the file is not comma
         deliminated. Usaully I could just break it apart at the white space
         but as you can see above, some of the street names (the third column)
         have whitespace in the text. I have almost declared it impossible
         and am about to give up an buy prepackaged/parsable software.
         I will feel very small if I have to do that.
         Thanks for any help,
         Ian

    public class CensusParser
         String[] census = {     "0001     A     Libby                       Ln     -92.99999+25.87787                 -92.87679+26.65543",
                                  "0002     A     Capri                       Ave     -93.32343+23.3332 3                -24.34444+34.22222",
                                  "0003     A     Minster Grove    Ln     -93.23433+22.2223432             -98.343343+23.34332",
                                  "0003     A     Houston               Ave    -91.99892+22.323322           -98.434543+33.33233",
                                  "0004    A       I-10                     Int    -91.23234+32.343232                 -97.333233+34.22222",
                                  "0005   C     Trenton Springs Ct.    -90.22232+33.222123           -91.234432+23.33221" };
         int cur, flds;
         String n = "";
         void parse() {
              for (int x=0; x<census.length; x++) {
                   flds = 0;
                   cur=census[x].length();
                   n = "";
                   for (int y=census[x].length()-1; y>=0 && flds < 4; y--) {
                        if (census[x].charAt(y) == '-' || census[x].charAt(y) == '+') {
                             n = "," + census[x].substring(y, cur).trim() + n;
                             cur = y;
                             flds++;
                   n = census[x].substring(0, cur).trim() + n;
                   census[x] = n;
                   System.out.println(n);
         public static void main(String[] args) {
              CensusParser cp = new CensusParser();
              cp.parse();
    }Not very efficient, but it works!
    Mark

  • Another SAX Parser Question

    Hi All,
    I get an xml file by making an http request. The name of the DTD comes as a relative path in the response xml file.
    Questions
    1. Is there a way to handle this
    2. I read somewhere that i could avoid looking at the DTD alltogether,
    can someone show me how with a sample code.
    Kind regards

    Nothing seems to help, Please help,
    Im using jdk1.4 A full source codee would be great.
    Thanks in advance.
    This is the trace and the Code follows below:
    C:\codes\parser>java -classpath xerces.jar;. ReaderConnector
    Initiating Connection to System URL = http://a.b.c.com:5280/vega/
    request?method=login&ui=ch16132-user&pwd=pass
    Connected ..
    Opening Stream for reading data
    Got input stream java.io.BufferedInputStream@19821f
    Got reader java.io.BufferedReader@addbf1
    Read login file ...
    Parsing ...
    Start of Login document
    \vega\xml\xrf.dtd (The system cannot find the path)
    Parsed
    ********************************3
    *****Code*****
    import javax.xml.parsers.*;
    import org.xml.sax.*;
    import java.io.*;
    import java.util.*;
    import java.net.*;
    import org.xml.sax.EntityResolver;
    import org.xml.sax.InputSource;
    import org.xml.sax.helpers.*;
    import org.xml.sax.ContentHandler;
    import org.xml.sax.Locator;
    import org.xml.sax.Attributes;
    import org.xml.sax.XMLReader;
    import org.xml.sax.helpers.XMLReaderFactory;
    * @author  JAVA
    * @version
    public class ReaderConnector{
        public ReaderConnector() {
        /*Login URl doesnt change*/
        private  String loginUrl  = "http://a.b.c.com:5280/vega/request?method=login&ui=ch16132-user&pwd=pass";
        //private  String loginUrl  = "c://temp/test.xml";
        private String sessionId;
        public String getSessionId(){
            if(sessionId == null){
                createConnection();
                return sessionId;
            }else{
                return sessionId;
        public void createConnection() {
            DataInputStream inputStream = null;              
            BufferedReader reader = null;
             InputStream in = null;
             FileOutputStream fos= null;
             //System.setProperty("javax.xml.parsers.SAXParserFactory",  "org.apache.xerces.jaxp.SAXParserFactoryImpl");
            try {
                URL url = new URL(loginUrl);
                URLConnection connection = url.openConnection();               
                connection.setUseCaches(false);               
                System.out.println(" Initiating Connection to System URL =  " + "http://a.b.c.com:5280/vega/request?method=login&ui=ch16132-usr&pwd=pass");
                connection.connect();
                System.out.println(" Connected ..");
                System.out.println(" Opening Stream for reading data ");
                 in = new BufferedInputStream (new DataInputStream (connection.getInputStream()));                                                               
                System.out.println("Got input stream "+ in);
                reader = new BufferedReader(new InputStreamReader(new BufferedInputStream(in)));                               
                System.out.println("Got reader "+ reader);
                System.out.println("Read login file ...");
                parseStream(reader);
            }catch (Exception e) {
                    System.out.println(e.getMessage());               
            }finally {
                try {
                    in.close();
                        //fos.close();
                    if (inputStream != null) {
                        inputStream.close();
                    if(reader!=null){
                        reader.close();
                } catch (Exception ex) {
                    System.out.println(ex.getMessage());
                    ex.printStackTrace();
         public void parseStream(BufferedReader br){
            System.out.println("Parsing ...");
            try{           
                /*SAXParserFactory spf = SAXParserFactory.newInstance();
                spf.setValidating(false);
                spf.setNamespaceAware(false);
                org.xml.sax.Parser sp = (org.xml.sax.Parser)spf.newSAXParser();
                //sp.isValidating(false);
                sp.setDTDHandler(new Resolver());
                //sp.setDocumentHandler(new Handler());
                InputSource iSource = new InputSource(br);
                Handler h = new Handler();
                sp.parse(iSource );            */
              XMLReader parser;
              parser = XMLReaderFactory.createXMLReader();
              parser.setContentHandler(new Handler());
             parser.setDTDHandler(new Resolver());
              parser.parse(new InputSource(br));
            }catch(Exception e){
                System.out.println(e.getMessage());
            System.out.println("Parsed");
        public static void main(String [] args){
            ReaderConnector connector = new ReaderConnector ();
            //connector.testParsing("c://temp/test.xml");
            connector.createConnection();
        private class Resolver extends DefaultHandler{
            public InputSource resolveEntity(String publicId, String systemId) throws SAXException {
          System.err.println(publicId + " ! " + systemId);
          if (("/vega/xml/xrf.dtd").equalsIgnoreCase(systemId) || ("/vega/xml/xrf.dtd").equalsIgnoreCase(publicId))
            try {
              return new InputSource(new URL("http://a.b.c.com:5280"+systemId).openStream());
            } catch (MalformedURLException e) {
              throw new SAXException(e);
            } catch (IOException e) {
              throw new SAXException(e);
          else return null;
        private class Handler extends org.xml.sax.helpers.DefaultHandler{                      
            public void startDocument() throws org.xml.sax.SAXException {
                System.out.println("Start of Login document");           
            public void endDocument() throws org.xml.sax.SAXException {           
                System.out.println("End of document");
            public void ignorableWhitespace(char[] values, int param, int param2) throws org.xml.sax.SAXException {
            public void endElement(java.lang.String str, java.lang.String str1, java.lang.String str2) throws org.xml.sax.SAXException {
                System.out.println("End of element reached: str, str1, str2 "+ str + " , "+ str1 + " , "+ str2);
                System.out.println("Session ID "+ sessionId);
            public void skippedEntity(java.lang.String str) throws org.xml.sax.SAXException {           
            public void processingInstruction(java.lang.String str, java.lang.String str1) throws org.xml.sax.SAXException {           
            public void startElement(java.lang.String str, java.lang.String str1, java.lang.String str2, org.xml.sax.Attributes attributes) throws org.xml.sax.SAXException {                            
                if(("A").equals(str2)){
                    for(int i=0; i< attributes.getLength();i++){
                        System.out.println("Attribute "+ i + ", Name, Value "+ attributes.getQName(i) + ", " + attributes.getValue(i));
                        if(("v").equalsIgnoreCase(attributes.getQName(i)))
                            sessionId = attributes.getValue(i);
            public void endPrefixMapping(java.lang.String str) throws org.xml.sax.SAXException {
            public void startPrefixMapping(java.lang.String str, java.lang.String str1) throws org.xml.sax.SAXException {
            public void characters(char[] values, int param, int param2) throws org.xml.sax.SAXException {           
                String s =  new String(values);
                String text = s.substring(param, param+param2);                       
            public void setDocumentLocator(org.xml.sax.Locator locator) {
    XML File
      <?xml version="1.0" encoding="ISO-8859-1" ?>
      <!DOCTYPE XRF (View Source for full doctype...)>
    - <XRF r="2.11.1" c="" g="" u="ch16132-user" k="" d="20050614" t="151146">
      <A k="i0005" n="3" v="1964216949" />
      </XRF>
    ****When you view source*******
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!DOCTYPE XRF SYSTEM "/vega/xml/xrf.dtd">
    <XRF r="2.11.1" c="" g="" u="ch16132-user" k="" d="20050614" t="151722">
    <A k="i0005" n="3" v="350287547"/>
    </XRF>

  • Interesting SAX Parser Question

    I am running a BEA Sample weblogic server and trying to parse in XML using SAX.The endElement in the sample program to parse the XML takes only one parameter like follows
    public void endElement(String name) throws SAXException {
    its not taking the local name.. in that case what should i do .. i won;t get the local name
    I tried to change it to as follows
    public void endElement(String namespaceURI, String localName,
    String name)throws SAXException
    and printing the localName.. its always empty.
    The sample code extends like this..
    public class RequestHandler extends DefaultHandler {
    Will it make any difference ? If i extend from ContentHandler will it solve the problem ? .. Please help me
    Thanks,
    -Raj..

    Thanks sir and figured that out earlier itself..
    My question now is why i am not getting the "localName" in startElement & endElement function when i extend my class using DefaultHandler ?
    I know if the Namespace is false or not present i won't get the localName.
    But my XML has namespace .. and i get the "localName" when i extend the class using ContentHandler .. at the same time when i extend my class using DefaultHandler i am not getting the "localName" .. Do i need to explicity perform the Namespace processing ??
    I am confused why i am getting localName when i extend from ContentHandler & not when i extend it from DefaultHandler ?
    class MyHandler extends DefaultHandler {
    public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
    // localName is always empty here
    public void endElement(String uri, String localName, String qName) throws SAXException {
    // localName is always empty here
    class MyHandler extends ContentHandler {
    public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
    //localName has Expected Value
    public void endElement(String uri, String localName, String qName) throws SAXException {
    //localName has Expected Value
    This is the XML i have :
    <?xml version="1.0" encoding="UTF-8"?>
    <SubscriberNotification xmlns:cng="http://cs.com/CSI/Namespaces/Types/Public/DataModel.xsd"
    xmlns="http://cs.com/Namespces/Container/JMS/SubscriberNotification.xsd"
    xmlns:sn="http://cs.com/Namespaces/Container/Public/SubscriberNotification.xsd"
    xmlns:mh="http://cs.com/Namespaces/Container/Public/MessageHeader.xsd">
    <mh:TrackingMessageHeader>
    <cng:version>v3</cng:version>
    </mh:TrackingMessageHeader>
    <sn:SubscriberNotification>
    <sn:DateTime>2003-12-10T11:17:27.377Z</sn:DateTime>
    <sn:Subscriber>
    <sn:subscriberNumber>1234567890</sn:subscriberNumber>
    </sn:Subscriber>
    </sn:SubscriberNotification>
    </SubscriberNotification>

  • XML - SAX Parsing Question

    Hi,
    I am parsing XML using SAX parser and fill the values into the HashTable ( like Key value pair ).. so i can get the vaues for a particular key using hash get function.
    For the following XML. There are 2 "subscriberNumber" attribute, one is under "sn:Subscriber" and the another is under "sn:SubscriberChange".
    I can able to put this values in hash table and when i print the Hash table it is printing as sn:subscriberNumber=[1234567890, 1234567890] .. But how will i know which one is from "sn:Subscriber" and which is from "sn:SubscriberChange"
    This is the XML :
    <sn:SubscriberNotification>
    <sn:notificationSubType>1120</sn:notificationSubType>
    <sn:Subscriber>
         <cng:PaymentType>PostPaid</cng:PaymentType>
         <sn:subscriberNumber>1234567890</sn:subscriberNumber>
    </sn:Subscriber>
    <sn:SubscriberChange>
         <sn:subscriberNumber>1234567890</sn:subscriberNumber>
    </sn:SubscriberChange>
    </sn:SubscriberNotification>
    Any suggestion and pointers are really helpful
    Thanks,
    -Raj..

    Try something like this:
    import java.util.Stack;
    import org.xml.sax.Attributes;
    import org.xml.sax.SAXException;
    import org.xml.sax.helpers.DefaultHandler;
    class MyHandler extends DefaultHandler {
        Stack openTags = new Stack();
        public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
            if (qName.equals("sn:subscriberNumber")) {
                String parentTag = (String)openTags.peek();
                System.out.println("Parent tag of this <sn:subscriberNumber> is : <" + parentTag + ">");
            openTags.push(qName);
        public void endElement(String uri, String localName, String qName) throws SAXException {
            openTags.pop();
    }Regards

  • DBMS_SQL.PARSE Question

    Hi,
    From the PL/SQL packages doc:
    DBMS_SQL.PARSE Procedure
    This procedure parses the given statement in the given cursor.
    All statements are parsed immediately. In addition, DDL
    statements are run immediately when parsed.Any reason as to why DDL statements are executed when passed
    to DBMS_SQL.PARSE ?
    Rgds.
    Amogh

    I think you are asking for alternate of dbms_sql.parse,
    so you can use native dynamic sql:
    SQL> create or replace procedure exec_ddl
      2  as
      3  begin
      4    execute immediate 'create table sample_table(x varchar2(1))' ;
      5  end;
      6  /
    Procedure created.
    SQL> exec exec_ddl
    PL/SQL procedure successfully completed.
    SQL> desc sample_table
    Name                                      Null?    Type
    X                                                  VARCHAR2(1)

  • Any bright ideas? (string parsing question)

    Hi,
    I need to put together some static methods for parsing and comparing strings in different formats. I've written the skeleton methods with some nice comments below:
    public class ParsingTools {
        * This method should be able to convert a string that contains
        * a date in an arbitrary format, to a java.util.date.
        * E.G. '10.12.1998 4:15 AM', 'Jan 6th 1984', '1/01/00'
        * '24th Feb 1975 0530hrs'.  The boolean 'usa' parameter indicates
        * whether its usa style dates: mm/dd/yyyy, instead of dd/mm/yyyy.
        * @param inputDate
        * @param usa
        * @return
       public static Date parseStringDate(String inputDate, boolean usa){
          Date outputDate = null;
          return outputDate;
        * This method should be able to convert strings like:
        * "$10,000.45" to the double 10000.45, or even:
        * "'x=$$254,433,344.003'" to 254433344.00.  All kinds of
        * extraneous characters could be received, this method extracts
        * and returns the number part.
        * @param inputString
        * @return
       public static double parseMoneyString(String inputString){
          double outputDouble = 0.0;
          return outputDouble;
        * This method takes two strings, the first of which is compared
        * to the second to see if they are a close enough match.
        * E.G. " exerci$ed_" compared with "EXERCISED" should return
        * true, but "elephant" compared with "EXERCISED" should return
        * false.
        * @param inputString
        * @param compareString
        * @return
       public static boolean matchToString(String inputString,
                                           String compareString){
          boolean matches = false;
          return matches;
    }Ok, the getting the double from the money string one is easy, just search through the string until you find some numbers, and strip out any commas.
    If anyone has any ideas on a clever way of doing the date parsing, and the string compare one, or knows of existing methods to do these, I'd love to hear about it.
    Many long hours of messing around with string operations await me otherwise!
    Thanks

    I need to put together some static methods for
    parsing and comparing strings in different formats.
    I've written the skeleton methods with some nice
    e comments below:Why isn't java.text.DateFormat good enough for you? I'll bet they do it better.
    I'd use Locale for currencies.
    This is a case where stuff that's already available to you should be preferred. Why write your own when someone else has already done it better? You don't have to maintain it, either. JMO, of course.
    >
    public class ParsingTools {
    * This method should be able to convert a string
    ring that contains
    * a date in an arbitrary format, to a
    to a java.util.date.
    * E.G. '10.12.1998 4:15 AM', 'Jan 6th 1984',
    84', '1/01/00'
    * '24th Feb 1975 0530hrs'.  The boolean 'usa'
    usa' parameter indicates
    * whether its usa style dates: mm/dd/yyyy,
    yyy, instead of dd/mm/yyyy.
    * @param inputDate
    * @param usa
    * @return
    public static Date parseStringDate(String
    ing inputDate, boolean usa){
    Date outputDate = null;
    return outputDate;
    * This method should be able to convert strings
    ings like:
    * "$10,000.45" to the double 10000.45, or even:
    * "'x=$$254,433,344.003'" to 254433344.00.  All
    All kinds of
    * extraneous characters could be received, this
    this method extracts
    * and returns the number part.
    * @param inputString
    * @return
    public static double parseMoneyString(String
    ing inputString){
    double outputDouble = 0.0;
    return outputDouble;
    * This method takes two strings, the first of
    t of which is compared
    * to the second to see if they are a close enough
    ough match.
    * E.G. " exerci$ed_" compared with "EXERCISED"
    SED" should return
    * true, but "elephant" compared with "EXERCISED"
    SED" should return
    * false.
    * @param inputString
    * @param compareString
    * @return
    public static boolean matchToString(String
    ing inputString,
    String
    String
    String compareString){
    boolean matches = false;
    return matches;
    }Ok, the getting the double from the money string one
    is easy, just search through the string until you
    find some numbers, and strip out any commas.
    If anyone has any ideas on a clever way of doing the
    date parsing, and the string compare one, or knows of
    existing methods to do these, I'd love to hear about
    it.
    Many long hours of messing around with string
    operations await me otherwise!
    Thanks

  • JAXP DOM simple parsing question.

    I am adament that I should use Java DOM Document,Node,Element,Attr classes
    to handle an xml document.
    Why is it that the following code, compiled and executed in the same directory as
    the xml file video.xml, only prints null, when it should echo
    the contents to screen? I am running Windows XP SP2.
    import org.w3c.dom.*;
    import javax.xml.parsers.*;
    public class Main {
    public static void main(String[] args) {
    try {
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document xml = builder.parse(new String("video.xml"));
    System.out.println(xml.getTextContent());
    catch (Exception e)
    e.printStackTrace();
    //********************************************************************************

    I am adament that I should use Java DOM Document,Node,Element,Attr classesThat is very bad.
    try something like this may work
    DOMSource domSource = new DOMSource(xml);
    StringWriter writer = new StringWriter();
    StreamResult result = new StreamResult(writer);
    TransformerFactory tf = TransformerFactory.newInstance();
    Transformer transformer = tf.newTransformer();
    //transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
    transformer.transform(domSource, result);
    String xmlString = writer.toString();
    System.out.println(xmlString);

  • String parser question based on oracle grammer

    If i have a string like :
    update employee
    set wtKey = name||pno||id
    where id is not null
    Then my API should return this when i pass "||"
    name||pno||id
    I tried doing it using ' ' as dilimiter and check to see if the parsed string has || but that won't work when the above update cmd is written in the following manner:
    update employee
    set wtKey = name || pno || id
    where id is not null
    (or)
    update employee
    set wtKey = name|| ' ' ||id
    where id is not null
    Is there any API or third party stuff that can perform such operation instead of we parsing it based on some assumptions.
    Any help would be appreciated

    Matt,
    In simple terms, whenever you change some thing, its needed to be logged for the recovery. So when we change Oracle's datablock's data, we are creating one entry. The change has an undo entry also related to it, this would go to the Undo block. Now 'go' means we are updating undo block's current image(whatever it may be) with our current undo image for our transaction, a change hence has to be logged, second redo entry. Transaction table again has to be updated to maintain the entries of the current transaction, some records over there are updated, hence redo.
    The basic thing is that Oracle would make sure that we have all the changes, where ever they are done, logged in the log files for the crash. In case we wont have it, we wouldn't be able to perform recovery.
    A very simplified explanation :-).
    Aman....

  • Parsing question

    I feel like I know how to do this but I was wondering if anyone would have any better ideas.
    I have table that stores an id, sequence number, and column for text (4000 BYTES). What I need to do is parse, based on either one or two words on the text column. Now the complete text could be in 1 to a bunch or rows. All records would have the same id but increasing sequence numbers. My idea is to loop through the records based on id and have some logic to search for those rows or place all the records for an id into a collection and loop it. There has to be a better way to do it than this. This might be taking a step backwards but could I fetch all the records into a string and parse it. I think this could cause memory problems if there are a lot of row with the same id.
    caveat: I can't change the column to something else.
    Any help would be appreciated.

    you can try
    select *
    from
      (select your_id_col,
        dbms_xmlgen.convert(extract(xmlagg(xmlelement(e, your_text_col || ' ') order by your_sequence_col) ,'//text()').getclobval(),1) txt
      from your_table
      group by your_id_col
    where lower(txt) like '%your_search_text%' and lower(txt) like '%your_search_text_2%' and .....

  • File Parsing question

    Say I have a fairly big file. Many megs, for example. My file can be formatted kind of the way I want, but it contains data in a key-value pair format, where the key is a long (ordered) and the value is a string of variable length.
    So, for example, it could look something like this:
    1blabla
    2bobob
    3gugugu
    99910102923tututu
    Now, I know I can get the value for a specific key by parsing the lines, reading a long when reading a string. This is fine.
    But I'm trying to be somewhat smarter. Since I know my longs are ordered, I'm thinking I can implement a search algorithm that looks in the middle of an interval for the looked value, to eliminate half the remaining options per pass.
    I can use randomaccessfile to get to some random point in the file. That's fine. But now, since I can be at any point of the file, I could be within the long, or somewhere within the string. What I'm looking for, and can't seem to figure out, is how to get back to the beginning of the long value, to read it correctly.
    Any pointers appreciated!

    First reason is I'm trying to build something for unstructured data. Databases are usually good only for structured data. I could put everything in text, I suppose.
    Second reason is databases are, in theory, slower than intelligent file-parsing. You have to generate the connection, have the dbms manipulate the data then return the data then have the driver translate it to something your programming language understands. I know, I Know, I'd have to work years to make something as efficient as an existing DB.
    Third reason is databases usually require a database engine, so if I wanted to make a standalone application, with, say, a jar file, I could avoid requiring of my userd to install some database application. Yes, there are some embedded database thignies out there.
    Fourth reason is curiosity. I want to see if I can do something like this because I've never done it before, and I'm interested in finding out if it's possible or not!

Maybe you are looking for

  • Acrobat Standard gives "Adobe acrobaat has stopped working" immediatly after clicking the icon .

    The computer is running Windows 7 x64 Below are the problem details: Problem signature:   Problem Event Name:    BEX   Application Name:    Acrobat.exe   Application Version:    11.0.7.79   Application Timestamp:    536b812b   Fault Module Name:    a

  • Mapping XML data to a PDF template

    Hello, I have an application that gets data from a database and merges it with merge fields in a word template via XML. I would like to merge the data to PDF templates instead of Word ones. I have already created the pdf template with the fields I ne

  • Setting Session item from outside of APEX

    Hi All, First a little background: I've been learning APEX for a couple of days now. I'm evaluating it to see if it's suitable for the application we need to make, otherwise it'll be done in PHP. The application needs to act as a web service client:

  • Episodes not showing in podcast

    Hi all, I'm trying to add my podcast feed to iTunes. The feed validates and the resulting XML <i>looks</i> correct to my obviously flawed vision, but for some reason iTunes and also Shrook, another RSS reader I tried using just to make sure, are seem

  • HT201364 I've downloaded Mavericks, but cannot set up the installation.

    I've downloaded Mavericks, but cannot set up the installation.  The clock just keeps turning, and I can't continue or exit.  Any idea of what to do next? I believe my system meets the requirements, although I'm not real sure of the age (I think I pur