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 .....

Similar Messages

  • 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

  • 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,

  • 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....

  • 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!

  • DOM parser question

    Hi,
    How can parse the following simple document using DOM and display the testnumber and region number values.
    <?xml version="1.0" encoding="UTF-8"?>
    <testCase xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="someURL">
    <testNumber>emp00001</testNumber>
    <regionNumber>2</regionNumber>
    </testCase>
    Thanks for your help.
    JavaKnr

    I did all those things.. But not able to get the values by tag name.
    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
    //Using factory get an instance of document builder
    DocumentBuilder db = dbf.newDocumentBuilder();
    String xml = null;
    InputSource inStream = new InputSource();
    inStream.setCharacterStream(new StringReader(xmlString.trim()));
    Document doc = db.parse(inStream);
    Element el = doc.getElementById("testNumber");

  • Re: Steve's book - PLSQL - Validation/DTD/Parser questions

    1)How much of the xpath plsql validation example in Steve's book (page 138 onwards) could (or should) be done by parsing with the appropriate DTD instead?
    2)If we receive an input XML doc that is missing the DTD line (reference to our published DTD) can we still enforce parsing with our DTD (without having to modify the input doc)?
    3)Can the plsql XML parser return all parse errors in one go (cf command line oraxml v filename)
    null

    We don't support file references ("cv1_0.dtd"). Only url type references
    are supported, of the form:
    @ <!DOCTYPE cv1 SYSTEM "http://www.oracle.com/public/cv1_0.dtd>
    Note that the url should be accessible to the world without the need to authenticate.
    you could put your dtd in the "public" area in your iFS system.
    Thanks,
    Sirisha
    null

  • Java sax parsing question

    Hi All,
    Any help is appreciated. Is it possible to start parsing an XML document somewhere in the middle of the document using SAX parser? It will still parse the doc sequentially but has to start at a specified location or sorts instead of starting from the beginning.
    Thanks in advance.

    Sure. Open an InputStream on the document (a FileInputStream or whatever is convenient). Read the part of the InputStream before the document and ignore the data. When you have the InputStream's cursor pointing at the beginning of the document, pass it to the parser.

  • One tuff parsing question?

    I read in three lines of data.
    This is what the data looks like:
    Joe|22|math|A
    Ladan|21|english|C
    Kyle|22|accounting|F
    Can someone please show me code that will return a string that looks like this...
    return String Results = "math|english|accounting";

    Try this:
    BufferedReader br=new BufferedReader(new InputStreamReader(inputStream));
    String nextLine="";
    String retStr="";
    StringBuffer sBuf=new StringBuffer();
    char pChar='|';
    int pLoc=2;
    while((nextLine=br.readLine())!=null) {
    try {
    retStr=doStuff(nextLine, pLoc, pChar);
    catch(Exception ex) {
    System.out.println("Error parsing a line");
    continue;
    sBuf.append(retStr);
    sBuf.append(pChar);
    String lastStr=sBuf.toString();
    lastStr.substring(0, lastStr.length()-1);
    public String doStuff(String thLine, int pLoc, char pChar)
    throws Exception {
    //pLoc is the index of the token to find
    //pChar is the delimiter character
    int lLen=thLine.length();
    int stInd=0;
    int fiInd=-1;
    for(int count=0;;count++) {
    stInd=thLine.indexOf(pChar, stInd);
    if(stInd==-1)
    throw new Exception();
    if(count==pLoc) {
    fiInd=thLine.indexOf(pChar, stInd+1);
    if(fiInd==-1)
    return thLine.substring(stInd+1, thLine.length());
    return thLine.substring(stInd+1, fiInd);
    stInd+=1;
    }

Maybe you are looking for