NodeList and getElementsByTagName

Hi guys, I have a great problem, and I cannot solve them, therefor I like get some your help!!!!
I have a xml document:
<transformers>
    <transformer>
        <name>transformer1</names>
    </transformer>
        <transformer>
        <name>transformer2</names>
    </transformer>
        <transformer>
        <name>transformerN</names>
    </transformer>
</transformers>And I wanna create a function that remove a "transformer" based on the name value. Then I create the method:
public void delete(String tag, String name)
    ListNode list = xmlTree.getElementsByTagName(tag);
    System.out.pritln("SIZE LIST: " + list.getLength());
    for(int i = 0; i < list.getLength(); i++)
        System.out.println("NODE[" + i + "]: " + list.item(i));
        if(list.item(i).getNodeValue().equals(name))
            list.item(i).getParentNode().removeNode(list.item(i));
    }//End for
}//End delete() methodThen I call :
delete("name", "transformer2");And I get the result:
SIZE LIST: 3 //Thats OK, I just had three nodes
NOD[0]: null //Why I always get null, if the list had three nodes?!?!?
NOD[1]: null
NOD[2]: null
Someone can help me??!? Thanks
Giscard

The value of an element is not the text that is inside the node. You would need to call
getFirstChild, getNextSibling to collect the text, and then do the compare.

Similar Messages

  • What's usage of DataStructure NodeList and CPData

    I read the Oraxml.hpp file and see the
    class NodeList NamedNodeMap ListLink CPData
    anybody can tell me what's the meaning of these data structure .

    NodeList defines an ordered collection of nodes, While NamedNodeMap dont' have specific order which represents collections of nodes that can be accessed by name.
    Please check DOM specification at
    www.w3c.org for further information.

  • GetChildNodes() and getElementsByTagName()

    hi,
    i'm using java's built-in DOM xml parser. i have a very simple xml document:
    <?xml version="1.0" encoding="iso-8859-2"?>
    <form title="BSA" x="150" y="150" w="240" h="180">
         <label name="label1" text="abcd: "
              x="10" y="10" w="100" h="20" />
         <border>
              <label name="label2" text="123"
                   x="120" y="10" w="100" h="20" />
         </border>
    </form>
    my problem is the following:
    i only need the elements that are direct children of the <form> element (or direct children of any other element).
    however, if i call the getElementsByTagName("label") method on the <form> element, i get ALL the elements named "label" in the document.
    in this case, getElementsByTagName() returns:
    <label>
    <label>
    if i call the getChildNodes() method on the same element, i get twice as many elements as there are direct children in the <form> element.
    like this:
    getChildNodes() output:
    #text
    <label>
    #text
    <border>
    i don't know where the "#text" elements come from and what they represent, but there's allways one for each child element.
    so, how do you get all direct children of an element?
    i coluld just discard the "#text" elements but i'd sitll like to know what they are and whether there could be some other "invisble" "#something" elements.
    thanks

    The # text nodes are ignorableWhitespace nodes.
    Refer to http://java.sun.com/xml/jaxp/dist/1.1/docs/tutorial/dom/2b_display.html

  • How to loop through many XML messages and parse them ?

    Hi All
    I have been trying very hard to loop through many XML messages and process each of them. Let me first explain the problem -
    Suppose I have the following String -
    <xyz>
    <abc>happy</abc>
    </xyz>
    <xyz>
    <abc>new</abc>
    <xyz>
    <xyz>
    <abc>year</abc>
    </xyz>
    I have to process each message within the <xyz></xyz> tag and find the falue of <abc> element (happy, new and year).
    The extraction of <abc> value is very simple, I am using SAX parser's startElement() method to check every element's name and if the element's name is <abc> pick up the value. But I am not able to loop through the different messages within the <xyz></xyz> tag.
    I am thinking of using another DOM parser -
    DOMParser domParser = new DOMParser();
    StringReader rdr = new StringReader(inputXML);
    InputSource src = new InputSource(rdr);
    domParser.parse(src);
    Document doc = domParser.getDocument();
    NodeList nodeList = doc.getElementsByTagName("xyz");
    Now I can loop through this nodeList, but not able to. Is using the DOM parser and NodeList the preferable way of lopping through the messages, then how I can loop through ? Or is there any other way ?
    I have been trying on this for quite a few days, but not able to. Can you please help me out ?
    Thanking you in advance ....
    Nirmalya Sinha

    Hi,
    Try using the SAX reader from the dom4j package. The document object that you receive contains methods for getting the root elements and with that you can traverse down to the sub elements of it.
    Hope this was of some help.

  • Xml traversal and tree manupulation

    I am new to the java xml processing hope to get some help here ...
    Curretly I have a xml document which look like this
    <chapter>
    <para> <grpref ref="xxx"/> <grpref ref="yyy"/> </para>
    <para> <grpref ref="yyy"/> </para>
    <graphic id="xxx"></graphic>
    <graphic id="yyy"></graphic>
    </chapter>
    I need to do a traveral through the xml tree
    1. check for element para
    2. if detect para, I need to search for element grpref under the para
    3. if have, I need to copy the graphic element which same level as para
    can someone guide me on this?

    You already have the Document object, right?
    In that case, use the Document's getDocumentElement() method to get the root element node. Then, use the Element method getElementsByTagName("para") ; this will return a NodeList of all descendants of <chapter> with tagname <para> (note that this applies even if <para> isn't a direct child of <chapter>; watch out for that). Then, you can use a for loop to go through the NodeList, cast the Nodes into Elements, and do getElementsByTagName("grpref") (again, this returns all descendants, not just children).
    Now, you can use a for loop to go through the NodeList of <grpref> elements, using Node.getAttributes().getNamedItem("ref").getNodeValue() to get the "ref" attribute's value. For each <grpref> in the for loop, you could then use getDocumentElement().getElementsByTagName("graphic") to get a list of all the <graphic> elements; nest in a for loop to search through the <graphic> element NodeList and, for each <graphic> element, use Node.getAttributes().getNamedItem("id").getNodeValue() to get the <graphic>'s ID, and compare it to the ref you have from the <grpref>; break out when you've found the right <graphic>
    Get all that?

  • How to get  xml Element , data and its Childs

    hi,
    I am trying to get entire Element and its childs depending on condition.
    suppose
       if(doc.element.name== "despatch"){
                   // here i want entire despatch element with data and childs and copy into one string like
                   // eg: String dsp = <despatch><name>body1</name> <value>value1<value>
    </despatch>
    <?xml version="1.0">
    <handler>
         <name>header1</name>
         <value>value1</value>
    </handler>
    <despatch>
         <name>body1</name>
         <value>value1<value>
    </despatch>
    <gov>
         <name>env</name>
         <value>value1</value>
    </gov>I managed to get number of elements depending on the Element name but i need to get the entire block.
    nodeList = document.getElementsByTagName("despatch").item(0).getChildNodes();
                        for(int i=0;i<nodeList.getLength();i++){
                             System.out.println("i :"+document.getElementsByTagName("m:Security").item(i));
                        }any kind of help is appreciated.
    Han.
    Edited by: HANRAM on Apr 24, 2008 2:48 AM

    Hi Kartik,
    This one is similar to my question to print and email invoice at same time.  I pass itcpo-tdgetotf = 'X' in order to get otfdata and send email with the attachment of otfdata.
    Now I have data in otfdata, but when I call print_otf function, I clear out itcpo-tdgetotf, and passed
    itcpo-tddest = device_type but I still get error message said 'Handler not valid for open spool request'.
    Can you give me a working example that you have otfdata table and print data from that table.  I also post my question on other thread
    submit report and export to memory
    thanks

  • DOM Parser Transformer and tags without value

    hi all
    i;m trying to modify an xml
    the code is given below.
    DOMSource source = new DOMSource(a_doc);
    StreamResult result = new StreamResult(new FileOutputStream(a_path));
    TransformerFactory transFactory = TransformerFactory.newInstance();
    Transformer transformer = transFactory.newTransformer();
    transformer.transform(source, result);
    my problem is a tag with no value lake <tag></tag> it is converted into <tag /> in the result.
    can anybody help me to get the tag as it is?

    hi patterson,
    i'm just changing the values of some tags.
    the code i'm using is given below.
    NodeList nodeList = a_doc.getElementsByTagName(a_elementNodeName);
         int rootNodeListLen = nodeList.getLength();
         for(int i=0;i<rootNodeListLen;i++)
              System.out.println("inside element");
              Node rootNode = nodeList.item(i);
              if(rootNode == null) continue;
              String parentNodeName = rootNode.getParentNode().getNodeName();
              if(parentNodeName!=null )
                   if(rootNode.getFirstChild() == null) continue;
                   String value = rootNode.getFirstChild().getNodeValue();
                   if(a_hashTable.containsKey(value))
                        rootNode.getFirstChild().setNodeValue((String) a_hashTable.get(value));
    can u help me on this?

  • Use 1 stylesheet  for 2 DOMSources and get 1output

    Hello,
    I have to use 1 xsl stylesheet on 2 different DOMSources. I succeed for 1 DOMSource. Therefore I tried to merge the DOMSources to make 1 of them, but then got errors. I tried to connect them by first make them a document and use nodelist and appendchild like i see a lot in the forum, but that didn't work.
    somebody can help me?

    The easiest way to do this, I think, involves copying the Music folder from OS X to the new hard drive. Then delete the old Music folder from the OS X drive. Create an alias to the new Music folder, copy it to your home folder, and rename it to the same name as the folder you copied. (i.e. copy /Users/john/Music/iTunes to AUDIO/Music/iTunes, then create an alias to iTunes and copy it to /Users/john/Music. Rename the alias to iTunes.)
    Dealing with Windows is more difficult, as only Explorer follows shortcuts (NTFS doesn't support 'true' symlinks). I think you can set iTunes to read the AUDIO/Music/iTunes folder as its library folder in Edit > Preferences.
    Good luck.

  • How get all child elements from XML

    Hi
    I have one xml i tried to parse that xml using dom parser and i need to get some child elements using java
    <Group>
    <NAME>ABC</NAME>
    <Age>24</AgeC>
    ---------some data here......
    <Group1>
    <group1Category>
    <NAME>ABCTest</NAME>
    <age>27</Age>
    ----Some data here
    <group1subcategory>
    <subcategory>
    <NAME>ABCDEF</NAME>
    <age>28</Age>
    my intention was
    get group name (here ABC) i need all other name value from group1category ,group1 subcategory but pblm that
    my xml contains any number of Group nodes...but only i want name contains ABC
    i wriiten code like this
    DocumentBuilderFactory factory = DocumentBuilderFactory
    .newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document document = builder.parse(xmlFile);
    NodeList nodeList = document.getElementsByTagName("*");
    for (int i = 0; i < nodeList.getLength(); i++)
    Element element = (Element) nodeList.item(i);
    what is next step i need to do..please help

    964749 wrote:
    Sorry for inconvenience caused..i only asked if any ideas i not ask any body to spent time for me...
    This is simple code developed using xpath..i not know how i proceed further
    public class Demo {
    public static void main(String[] args) {
    DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
    try {
    DocumentBuilder builder = domFactory.newDocumentBuilder();
    Document dDoc = builder.parse("hello.xml");
    XPath xpath = XPathFactory.newInstance().newXPath();
    javax.xml.xpath.XPathExpression expr = xpath.compile("//Group/NAME");
    Object Name= expr.evaluate(dDoc, XPathConstants.STRING);
    System.out.println(Name);
    } catch (Exception e) {
    e.printStackTrace();
    i need get group name (here ABC) i need all other name value from group1category ,group1 subcategory but pblm that
    ..how i done in XPATH and also do manipulation of remining result...
    i also try with DOM like
    NodeList nodeList = document.getElementsByTagName("GROUP");
    for (int i = 0; i < nodeList.getLength(); i++)
    Element element = (Element) nodeList.item(i);
    if (element.getNodeName().matches("ECUC-MODULE-DEF"))
    String str=((Element) nodeList.item(i)).getElementsByTagName("NAME").item(0).getFirstChild().getNodeValue();
    if(str.equalsIgnoreCase("abc")){
    NodeList children = element.getChildNodes();
    for (int k = 0; k < children.getLength(); k++) {
    Node child = children.item(k);
    System.out.println("children"+children.getLength());
    if (child.getNodeType() != Node.TEXT_NODE) {
    if(child.getNodeName().equalsIgnoreCase("Group1"))
    how iterate for particular ABC name to group1 and subcategoryFew things
    1. Use code tags to format code
    2. Explain the problem statement clearly. Take time to formulate your question. Explain what you expect from your code and what you are getting along with any exceptions that are being thrown

  • End of communication file error ....for xmldom

    Hi,
    Below is a procedure that i am executing.
    I am using NOCOPY For the clob variable.
    While executing the procedure for an xml value for clstring i am getting an error like
    --end of communication channel.
    The xml data is very big but not more that the size for clob.
    procedure Prc_UpdateNodes(clString in out NOCOPY CLOB, nodename varchar2, nodeValue varchar2) is
            l_doc_node xmldom.DOMNode;
            l_xml_out varchar2(2000);
            begin
                      domDocument      := Fn_GetXmlDocument(clString);
                   nodeList           := xmldom.getElementsByTagName(domDocument, nodename);
                   intNoOfNode       := xmldom.getLength(nodeList);
                   l_doc_node := xmldom.item(nodeList, 0);
                   --xmldom.writetobuffer(l_doc_node, l_xml_out);
                   PKS_DEBUG.PRC_DEBUG('CLOB IN PRC_UPDATE' || clString);
                   for loopCount_int in 0.. intNoOfNode - 1  loop
                     node := XmlDom.item(nodeList, loopCount_int);
                        valueNode := XmlDom.getFirstChild(node);
                        --xmldom.writetobuffer(node, l_xml_out);
                        --This return value would be useful only in case of single record where in we could use the same after the insert operation is done
                        -- so that it could be used for the subsequent retrieval.
                        -- In case of multiple records update, this information remains of no use and doesnt have to be handled.
                        XmlDom.setNodeValue(valueNode,nodeValue);
                        --xmldom.writetobuffer(valueNode, l_xml_out);
                   end loop;
                   PKS_DEBUG.PRC_DEBUG('CLOB AFTER PRC_UPDATE' || clString);
                   XmlDom.writeToClob(domDocument,clString);
                   PKS_DEBUG.prc_debug('REMOVING BUFFER');
                  PRC_REMOVE_BUFFER(clString);
                   PKS_DEBUG.PRC_DEBUG('CLOB AFTER WRITITNG TO CLOB' || clString);
            end;The error occurs during the execution of the statement XmlDom.writeToClob(domDocument,clString);
    Do i need the above statement as i am using NOCOPY For the CLOB variable.
    Can anyone help me with this front..
    Thanks.

    checkout TNSPING <service name> from cmd prompt
    Microsoft Windows XP [Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.
    C:\Documents and Settings\NJi>tnsping issl
    TNS Ping Utility for 32-bit Windows: Version 2.3.2.1.0 - Production on 25-OCT-06
    14:36:06
    Copyright , 1996(c) Oracle Corporation 1995. All rights reserved.
    Attempting to contact (ADDRESS=(COMMUNITY=tcp.world)(PROTOCOL=TCP)(Host=198.1.2.
    15)(Port=1521))
    OK (100 msec)

  • ORA-22290: operation would exceed the maximum number of opened files or LOB

    i am getting this error in a procedure.
    ORA-22290: operation would exceed the maximum number of opened files or LOBs
    22290, 00000, "operation would exceed the maximum number of opened files or LOBs"
    // *Cause: The number of open files or LOBs has reached the maximum limit.
    // *Action: Close some of the opened files or LOBs and retry the operation.
    NAME TYPE VALUE
    session_max_open_files integer 10
    Procuedure:
    CREATE OR REPLACE PROCEDURE WMSOWN."PROC_WMS_XML_READ"
    P_EVENT_KEY IN VARCHAR2,
    X_STATUS_MSG OUT VARCHAR2,
    X_STATUS OUT NUMBER
    )AS
    l_parser dbms_xmlparser.Parser;
    domdoc xmldom.DOMDocument;
    nodelist XMLDOM.DOMNODELIST;
    node XMLDOM.DOMNODE;
    n_child XMLDOM.DOMNODE;
    elements XMLDOM.DOMELEMENT;
    name_node_map XMLDOM.DOMNAMEDNODEMAP;
    parent_seg varchar2(4000);
    tag_name_bkp varchar2(4000); -- LOOK OUT BRAD IS CODING AGAIN
    chile_seg VARCHAR2(4000);
    p_seg VARCHAR2(4000);
    p_seg1 VARCHAR2(4000);
    p_seg2 VARCHAR2(30);
    p_int_name VARCHAR2(50);
    col_value VARCHAR2(100):=NULL;
    len1 NUMBER;
    cnt NUMBER;
    seg_id_bkp NUMBER; -- LOOK OUT BRAD IS CODING AGAIN
    sequence_bkp NUMBER; -- LOOK OUT BRAD IS CODING AGAIN
    prev_sequence NUMBER; -- LOOK OUT BRAD IS CODING AGAIN
    prev_seq_set VARCHAR2(3); --brad coding
    parent_id number; ---brad coding
    valid_seg NUMBER; -- LOOK OUT BRAD IS CODING AGAIN
    data_status VARCHAR2(10);
    v_main_seg VARCHAR2(50);
    v_seq_no NUMBER;
    V_CLOBLOCATOR CLOB;
    V_FILELOCATOR BFILE;
    v_amount_to_load NUMBER;
    dest_offset NUMBER := 1;
    src_offset NUMBER := 1;
    lang_context NUMBER := DBMS_LOB.DEFAULT_LANG_CTX;
    warning NUMBER;
    v_event_name USR_OUB_FILE_PROCESS_DETAILS.EVENT_NAME%TYPE;
    v_file_name USR_OUB_FILE_PROCESS_DETAILS.FILE_NAME%TYPE;
    DIRECTORY_PATH_INVALID EXCEPTION;
    PRAGMA EXCEPTION_INIT(DIRECTORY_PATH_INVALID,-22285);
    NO_PRIVILEGES EXCEPTION;
    PRAGMA EXCEPTION_INIT(NO_PRIVILEGES,-22286);
    INVALID_DIRECTORY EXCEPTION;
    PRAGMA EXCEPTION_INIT(INVALID_DIRECTORY,-22287);
    FILE_NOT_FOUND EXCEPTION;
    PRAGMA EXCEPTION_INIT(FILE_NOT_FOUND,-22289);
    P_DIRECTORY VARCHAR2(50) :='WMS_XML_DIR_OUB';
    v_whid poldat_view.wh_id%type;
    BEGIN
    --NAME :  PROC_WMS_XML_READ.PLS
    --DESCRIPTION :
    -- Procedure PROC_WMS_XML_READ search XML files from remote location.
    -- Open,Parse and Read XML files. Store all XML values into tables.
    -- Developed by Dharmesh Patidar(jw782)
    -- History: New condition is added i.e. p_seg:=parent_seg to maintain PARENT and CHILD relationship
    -- by Vishwanath Dubey(jl246) on 17-June-2011
    -- BRAD_XML_DEBUG table removed for CLEANING Activity by DHARMESH PATIDAR(JW782) ON 29-JUNE-2011.
    /*BLOCK FOR CAPTURING EVENT NAME BASED ON EVENT ID START*/
    BEGIN
    SELECT event_name,file_name,WAREHOUSE_ID
    INTO v_event_name, v_file_name,v_whid
    FROM usr_oub_file_process_details
    WHERE event_id=p_event_key
    AND process_flag='U';
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    x_status_msg:=SQLCODE||':'||' Error while selecting event name and event id in Procedure PROC_WMS_XML_READ : Record is not available in USR_OUB_FILE_PROCESS_DETAILS table for event id '|| P_EVENT_KEY;
    x_status:=SQLCODE;
    proc_wms_error_trace(v_whid, --warehouse id
    null , --event id
    v_event_name , --event name
    x_status, --error code
    x_status_msg ); --error message
    RETURN;
    WHEN TOO_MANY_ROWS THEN
    x_status_msg:=SQLCODE||':'||' Error while selecting event name and event id in Procedure PROC_WMS_XML_READ : More than one Records found in USR_OUB_FILE_PROCESS_DETAILS table for event id '|| P_EVENT_KEY;
    x_status:=SQLCODE;
    proc_wms_error_trace(v_whid, --warehouse id
    null , --event id
    v_event_name , --event name
    x_status, --error code
    x_status_msg ); --error message
    RETURN;
    WHEN VALUE_ERROR THEN
    x_status_msg:=SQLCODE||':'||' Error while selecting event name and event id in Procedure PROC_WMS_XML_READ : Varibale length is small or data type mismatch while selecting event id and event name in USR_OUB_FILE_PROCESS_DETAILS table for event id '|| P_EVENT_KEY;
    x_status:=SQLCODE;
    proc_wms_error_trace(v_whid, --warehouse id
    null , --event id
    v_event_name , --event name
    x_status, --error code
    x_status_msg ); --error message
    RETURN;
    WHEN OTHERS THEN
    x_status_msg:=SQLCODE||':'||'Error in Procedure PROC_WMS_XML_READ while selecting event name and event id ';
    x_status:=SQLCODE;
    proc_wms_error_trace(v_whid, --warehouse id
    null , --event id
    v_event_name , --event name
    x_status, --error code
    x_status_msg ); --error message
    RETURN;
    END;
    /*BLOCK FOR CAPTURING EVENT NAME BASED ON EVENT ID END*/
    /*LOGIC TO READ XML FROM REMOTE LOCATION START*/
    DBMS_LOB.CREATETEMPORARY(V_CLOBLOCATOR, TRUE);
    V_FILELOCATOR := BFILENAME(P_DIRECTORY,V_FILE_NAME);
    DBMS_LOB.OPEN(V_FILELOCATOR,DBMS_LOB.FILE_READONLY);
    V_AMOUNT_TO_LOAD := DBMS_LOB.GETLENGTH(V_FILELOCATOR);
    DBMS_LOB.LOADCLOBFROMFILE(V_CLOBLOCATOR,
    V_FILELOCATOR ,
    V_AMOUNT_TO_LOAD,
    DEST_OFFSET,
    SRC_OFFSET,
    0,
    LANG_CONTEXT,
    WARNING);
    dbms_lob.close(V_FILELOCATOR);
    /*LOGIC TO READ XML FROM REMOTE LOCATION END*/
    /*Temporary Code to help with debug Clear the table before populating it with new data*/
    --delete table BRAD_XML_DEBUG;
    cnt:=1;
    seg_id_bkp:=0;
    data_status:='N';
    v_seq_no:=0;
    prev_seq_set:='NO';
    /*create new parser.*/
    l_parser := dbms_xmlparser.newParser;
    dbms_xmlparser.parseClob(l_parser, replace(V_CLOBLOCATOR,'&','1x2x3x4x5'));
    /*Parse the document and create a new DOM document.*/
    domdoc :=dbms_xmlparser.getDocument(l_parser);
    /* get all elements in the DOM*/
    nodelist := XMLDOM.getElementsByTagName(DOMDoc, '*');
    len1 := XMLDOM.getLength(nodelist);
    /* loop through elements of the DOM */
    FOR j in 1..len1-1 LOOP --MAIN LOOP START
    BEGIN
    /*below sql will fetch Node from table to travel xml data*/
    BEGIN
    SELECT int_name,tag_name
    INTO p_int_name, p_seg1
    FROM usr_wms_tag_det
    WHERE int_name=v_event_name
    AND seq_no =cnt;
    EXCEPTION
    --PLEASE DO NOT HANDLE ANY EXCEPTION APART MENTIONED BELOW
    WHEN OTHERS THEN
    NULL;
    END;
    IF cnt=1 THEN
    v_main_seg:=p_seg1;
    END IF;
    EXCEPTION
    --PLEASE DO NOT HANDLE ANY EXCEPTION APART MENTIONED BELOW
    WHEN no_data_found THEN
    null;
    WHEN OTHERS THEN
    x_status_msg:=SQLCODE||':'||'Error in Procedure PROC_WMS_XML_READ while selecting interface name and tag name'||sqlerrm;
    x_status:=SQLCODE;
    proc_wms_error_trace(v_whid, --warehouse id
    null , --event id
    v_event_name , --event name
    x_status, --error code
    x_status_msg ); --error message
    RETURN;
    END;
    /*LOGICS TO READ XML START*/
    node:=XMLDOM.item(nodelist, j);
    elements:=XMLDOM.makeElement(node);
    parent_seg:=(xmldom.getTagName(elements));
    tag_name_bkp:=(xmldom.getTagName(elements));
    name_node_map:=xmldom.getAttributes(node);
    n_child:=xmldom.getFirstChild(node);
    col_value:=xmldom.getNodeValue(n_child);
    /*get the sequence number from the interface hierarchy table */
    SELECT count(1)
    INTO valid_seg
    FROM usr_wms_tag_det
    WHERE int_name=v_event_name
    AND tag_name = tag_name_bkp;
    if valid_seg>0 then
    begin
    SELECT seq_no
    INTO sequence_bkp
    FROM usr_wms_tag_det
    WHERE int_name=v_event_name
    AND tag_name = tag_name_bkp;
    seg_id_bkp:=seg_id_bkp+1;
    p_seg:=parent_seg;--Modified by Vishwanath Dubey dated 16-jun-2011
    end;
    end if;
    if prev_seq_set = 'NO' then
    begin
    prev_sequence := sequence_bkp;
    prev_seq_set := 'YES';
    end;
    end if;
    if sequence_bkp < prev_sequence then --you just moved up level(s) in the message structure
    begin
    select max(seg_id)
    into parent_id
    from usr_wms_global_xml_det
    where seg_sequence = sequence_bkp-1;
    prev_sequence := sequence_bkp;
    end;
    end if;
    if sequence_bkp > prev_sequence then --you just moved down a level in the message structure
    parent_id := seg_id_bkp-1;
    prev_sequence := sequence_bkp;
    end if;
    /*end getting the hierarchy table sequence */
    /*LOGICS TO READ XML END */
    IF (parent_seg =p_seg1) or (parent_seg=p_seg2) THEN
    if parent_seg=v_main_seg then
    v_seq_no:=v_seq_no+1;
    end if;
    BEGIN
    /* INSERTING DATA LOGICS TO READ XML END */
    INSERT INTO usr_wms_global_xml_det values(p_int_name,tag_name_bkp,parent_seg,seg_id_bkp,sequence_bkp,parent_id,'','','',J,v_seq_no,data_status,cnt);
    EXCEPTION
    WHEN OTHERS THEN
    x_status_msg:=SQLCODE||' : Error in Procedure PROC_WMS_XML_READ while inserting records in USR_WMS_GLOBAL_XML_DET table for interface name and parent segment '||P_INT_NAME||','||PARENT_SEG;
    x_status:=SQLCODE;
    proc_wms_error_trace(v_whid, --warehouse id
    null , --event id
    v_event_name , --event name
    x_status, --error code
    x_status_msg ); --error message
    RETURN;
    END ;
    p_seg:=parent_seg;
    p_seg2:=P_SEG1;
    cnt:=cnt+1;
    ELSE
    chile_seg:=parent_seg;
    BEGIN
    /* INSERTING DATA LOGICS TO READ XML END */
    INSERT INTO usr_wms_global_xml_det values(p_int_name,tag_name_bkp,p_seg,seg_id_bkp,sequence_bkp,parent_id,'',chile_seg,replace(TRIM(Col_Value),'1x2x3x4x5','&'),J,v_seq_no,data_status,cnt);
    EXCEPTION
    WHEN OTHERS THEN
    x_status_msg:=SQLCODE||' : Error in Procedure PROC_WMS_XML_READ while inserting records in USR_WMS_GLOBAL_XML_DET table for interface name and parent segment '||P_INT_NAME||','||PARENT_SEG;
    x_status:=SQLCODE;
    proc_wms_error_trace(v_whid, --warehouse id
    null , --event id
    v_event_name , --event name
    x_status, --error code
    x_status_msg ); --error message
    RETURN;
    END;
    END IF;
    END LOOP; --MAIN LOOP END
    dbms_xmldom.freeDocument(DOMDoc);
    x_status:=0;
    EXCEPTION
    WHEN DIRECTORY_PATH_INVALID THEN
    x_status_msg:=SQLCODE||' : Error in Procedure PROC_WMS_XML_READ DIRECTORY PATH IS INVALID';
    x_status:=SQLCODE;
    proc_wms_error_trace(v_whid, --warehouse id
    null , --event id
    v_event_name , --event name
    x_status, --error code
    x_status_msg ); --error message
    RETURN;
    WHEN FILE_NOT_FOUND THEN
    x_status_msg:=SQLCODE||' : Error in Procedure PROC_WMS_XML_READ INVALID XML FILE NAME OR FILE DOES NOT EXISTS';
    x_status:=SQLCODE;
    proc_wms_error_trace(v_whid, --warehouse id
    null , --event id
    v_event_name , --event name
    x_status, --error code
    x_status_msg ); --error message
    RETURN;
    WHEN NO_PRIVILEGES THEN
    x_status_msg:=SQLCODE||' : Error in Procedure PROC_WMS_XML_READ Insufficient privileges on file or directory NAME- '||p_directory||' to perform FILEOPEN operation.';
    x_status:=SQLCODE;
    proc_wms_error_trace(v_whid, --warehouse id
    null , --event id
    v_event_name , --event name
    x_status, --error code
    x_status_msg ); --error message
    RETURN;
    WHEN OTHERS THEN
    x_status_msg:=SQLCODE||' : Error in Procedure PROC_WMS_XML_READ '|| SQLERRM;
    x_status:=SQLCODE;
    proc_wms_error_trace(v_whid, --warehouse id
    null , --event id
    v_event_name , --event name
    x_status, --error code
    x_status_msg ); --error message
    dbms_xmlparser.freeParser(l_parser);
    dbms_xmldom.freeDocument(DOMDoc);
    RETURN;
    END PROC_WMS_XML_READ;
    Edited by: user13427480 on Feb 8, 2013 7:08 PM

    when you post sql statement use also similar threads :
    ORA-22290: operation would exceed the maximum number of opened files or LOB
    https://kr.forums.oracle.com/forums/thread.jspa?messageID=10842417                                                                                                                                                                                                                                                                                                                                                                                                           

  • Is DocumentBuilder.parse(..) reading the whole XML into memory?

    Hello,
    I have a quick question about the following code snippet:
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document doc = builder.parse("books.xml");Please have a look at the last line "builder.parse("books.xml");". I would like to use XPath to retrieve some informations of a xml file without having to deserialize the whole file (since the XML file rather big and I need to go through several of them in a loop).
    What exactly does the "builder.parse(...)" method? Is it reading the XML file and writing all the content to memory? Or does it only analyze and read the structure of the XML code? Or in other words, is the text of an element "//books/title" in memory after parsing, or not until I really access the "title" node of that XML?
    Thanks a lot for your help
    Best Regards,
    Ben

    Hi ,
    I did'nt knew how to start a new thread , so i am asking the question here:
    ===========================================================
    I am trying to read a xml file but i am not able to do so properly. I am new to xml .
    am trying to read a xml file of the following format in the staf and stax job xml file:
    <?xml version="1.0" encoding="utf-8"?>
    <operating_system>
    <unix_80sp1>
    <tests type="quick_sanity_test">
    <prerequisitescript>preparequicksanityscript</prerequisitescript>
    <acbuildpath>acbuildpath</acbuildpath>
    <testsuitscript>test quick sanity script</testsuitscript>
    <testdir>quick sanity dir</testdir>
    </tests>
    <machine_name>u80sp1_L004</machine_name>
    <machine_name>u80sp1_L005</machine_name>
    <machine_name>xyz.pxy.dxe.cde</machine_name>
    <vmware id="155.35.3.55">144.35.3.90</vmware>
    <vmware id="155.35.3.56">144.35.3.91</vmware>
    </unix_80sp1>
    </operating_system>
    Here machine_name tag can be n number. I need to read all the machine_name tags in an array , so that i can use them later.
    Also i need to read all the vmware tags in an array (both value and attributes) so that i can use them later. The number of vmware tags can again be n numbers.
    I am trying to use the following code :
    <!-- ******************************************************************* -->
    <!-- Following function is used to parse an XML file and return the DOM -->
    <!-- document object -->
    <!-- ******************************************************************* -->
    <function name="parseXML" scope="local">
    <function-list-args>
    <function-required-arg name="xmlFileName">
    Name of file containing XML to be parsed
    </function-required-arg>
    </function-list-args>
    <sequence>
    <!-- Parse the XML -->
    <script>
    factory = DocumentBuilderFactory.newInstance();
    factory.setValidating(1)
    factory.setIgnoringElementContentWhitespace(0)
    builder = factory.newDocumentBuilder()
    document = builder.parse(xmlFileName)
    </script>
    <script>
    vmware = None
    machine_name = None
    # Get the text value for the element with tag name "vmware"
    nodeList = document.getElementsByTagName("vmware")
    for i in range(nodeList.getLength()):
    node = nodeList.item(i)
    if node.getNodeType() == Node.ELEMENT_NODE:
    children = node.getChildNodes()
    for j in range(children.getLength()):
    thisChild = children.item(j)
    if (thisChild.getNodeType() == Node.TEXT_NODE):
    machine_name = thisChild.getNodeValue()
    # Get the text value for the element with tag name "machine_name"
    nodeList = document.getElementsByTagName("vmware")
    for i in range(nodeList.getLength()):
    node = nodeList.item(i)
    if node.getNodeType() == Node.ELEMENT_NODE:
    children = node.getChildNodes()
    for j in range(children.getLength()):
    thisChild = children.item(j)
    if (thisChild.getNodeType() == Node.TEXT_NODE):
    machine_name = thisChild.getNodeValue()
    </script>
    <return>[machine_name,vmware]</return>
    </sequence>
    </function>
    I am able to read only one value for machine_name (u80sp1_L005) and also one value for vmware
    i.e 144.35.3.91.
    What i want is read all the machine_value tags into a list , so that i can use it later
    Also i want to read all the vmware tags attributes into a list and all corresponding values into another list.
    what i mean is considering the following:_
    <machine_name>u80sp1_L004</machine_name>
    <machine_name>u80sp1_L005</machine_name>
    <machine_name>xyz.pxy.dxe.cde</machine_name>
    <vmware id="155.35.3.55">144.35.3.90</vmware>
    <vmware id="155.35.3.56">144.35.3.91</vmware>
    read all machine_name tag values into one list (u80sp1_L004,u80sp1_L005,xyz.pxy.dxe.cde)
    also all vmware attributes into one list *(155.35.3.55,155.35.3.56).....*and all the vmware values into one list *(144.35.3.90,144.35.3.91)*
    Also a good link to understand parsing using doumentbilder factory would be good help.
    Regards
    Sangram
    mail: [email protected]

  • [XSQL] Displaying PDF stored in database as BLOB

    Dear Sirs,
    we have PDF stored in the database as BLOB.
    I have written a PLSQL function which I call accordingly
    <xsql:ref-cursor-function >
    digitallibrary.getdocs('{@resource_seqid}')
    </xsql:ref-cursor-function>
    however what I get is the following
    <page>
    <rowset>
    <row num="1">
    <document>255044462D312E320A...</document>
    </row>
    </rowset>
    </page>
    instead of having the customer's browser starting up Acrobat.
    It looks to me as if the data is the HEX of the BLOB:
    25 %
    50 P
    44 D
    46 F
    2D -
    31 1
    2E .
    32 2
    0A Line Feed
    This coincides with what previously reported
    "BLOB data is serialized as hex bytes in XSU."
    I understand that "XSQL has no built-in support for BLOB data, but it is extensible via user-written action handlers or user-written serializers."
    I have the feeling that I should use an appropriate serializer for this purpose but it is not entirely clear to me how ...
    Any suggestion is appreciated.
    Looking forward your advice.
    Regards and thanks
    Luca

    The following serializer
    public void serialize(Document document, XSQLPageRequest xsqlpagerequest) throws java.lang.Throwable {
    NodeList nodelist=document.getElementsByTagName("*");
    xsqlpagerequest.setContentType("application/pdf");
    OutputStream outputstream=xsqlpagerequest.getOutputStream();
    String DocString = new String();
    for (int loopIndex=0; loopIndex<=10; loopIndex++) {
    display(nodelist.item(loopIndex),"");
    if (loopIndex == 6 ) { DocString=displayStrings[loopIndex];}
    byte abyte0[] = oracle.xml.sql.core.OracleXMLConvert.convertHexStringToByte(DocString);
    outputstream.write(abyte0, 0, abyte0.length);
    outputstream.flush();
    works fine however the Internet Explorer 5.5 displays the native PDF code instead of firing the plugin... any suggestion ?

  • Single Item Access

    I am relatively new to XML / JAXP technologies and was wondering if there is a syntax available that would permit retrieving a node by specifying the ancestory of the node? For example, if I had the following XML:
    <?xml ?>
    <person name="Daffy">
    <address>
    <city>Hollywood</city>
    <state>CA</state>
    <zip>90210</zip>
    </address>
    </person>
    <person name="Donald">
    <address>
    <city>Pensicola</city>
    <state>FL</state>
    <zip>01209</zip>
    </address>
    </person>
    Is there a way to retrieve the city for Donald in a single access such that I don't have to walk the tree? Maybe use getElementsByTagName() and specify the ancestory with the value Donald somehow?
    By the way, is it considered good form to not put a value after a node that has children?
    Thanks,
    Derek

    just wrote a rough code..
    NodeList list=getElementsByTagName("person");
    for(int i=0;i<list.getLength();i++)
      Element temp= list.item(i);
      if(temp.getAttribute("name").equals("Donald "))
      break;
    }

  • Problem in reading XML contents

    Hi all,
    I have a problem in extracting a portion of the XML file.
    the XML is
    <x>
         <y1></y1>
         <y2>
              <value1>One</value1>
              <value2>Two</value2>
              <value3>Three</value3>     </y2>
         <y3></y3>
    </x>the code i have written is
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import org.w3c.dom.Document;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    public class DOMParserDemo
        public static void main(String s[]){
            try{
                DocumentBuilder docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
                Document document = docBuilder.parse("doc.xml");
                NodeList nodeList = document.getElementsByTagName("y2");
                Node node = nodeList.item(0);
                NodeList nList = node.getChildNodes();
                int len = nList.getLength();
                for(int i=0; i<len; i++){
                    System.out.println(nList.item(i).getNodeName());
            }catch(Exception e){
                e.printStackTrace();
    } I got the result as.
    #text
    value1
    #text
    value2
    #text
    value3
    #text
    where i expect the value to be prinited in the place of #text
    can any one please help me to display the content correctly.
    thanks in advance
    subra

    This gets the element's contents - using concat from the other thread - you just need to navigate down the tree to the right depth:      NodeList nodeList = document.getElementsByTagName("y2");
          // for every y2 element
          for (int index1 = 0, length1 = nodeList.getLength(); index1 < length1; index1++) {
            final Element y2 = (Element)nodeList.item(index1);
            final NodeList y2Children = y2.getChildNodes();
            // for every child of a y2 element
            for (int index2 = 0, length2 = y2Children.getLength(); index2 < length2; index2++) {
              final Node child = y2Children.item(index2);
              // if that child node is an element node
              if (child.getNodeType() == Node.ELEMENT_NODE) {
                Element element = (Element)child;
                // print it's name, and the concatenation of any text nodes nested in it
                System.out.println(concat(element.getChildNodes(),
                                          new StringBuffer(element.getNodeName()).append(" = ")));
          }Pete

Maybe you are looking for

  • AP Check PLD Not Printing Stub Information

    Hello, When printing an AP Check (PLD stub-check-stub) for a misc vendor (outgoing payment -> account). The stub portions does not print any data, only prints text. It does print fine for vendors. How do I get  the stub information to print for these

  • How do I designate myself in my iCloud contacts to use for autofill

    how do I designate "myself" in my iCloud contacts to use for autofill

  • Firefox will only open once

    I can run Firefox once per profile & then it won't start again. I have to make a new profile to get it to open again. Alternatively, I can start Safe Mode and then exit after the prompt with the options to enter Safe Mode. After that I can start Fire

  • Which Oracle XE dialect?

    Please, could help me? I am a new user Oracle, could help me, please? Which dialect for Oracle XE could usage in the Hibernate? I already used OracleDialect and Oracle9Dialect, but it didn't function. Certain of your understanding, at once I thank. U

  • =?iso-8859-1?Q?OT:_ayuda_con_art=EDculos?=

    This is a multi-part message in MIME format. ------=_NextPart_000_0006_01C699ED.D3886CB0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Estoy montando una serie de plantillas para un portal que estoy = cons