Looping through XML Items

Hi,
I am selecting data from tables in forms of xml like below
xml_data VARCHAR2(32000) :=
SELECT XMLELEMENT("form",
xmlagg(xmlelement("item",
XMLFOREST(form_seq_no "form_seq_no",
patientid "patientid",
facilityid "facilityid"
from (SELECT
e.form_seq_no,
e.patientid,
e.facilityid
FROM hosp e
I am using a cursor like below to get the data
OPEN l_rc FOR xml_data;
LOOP
if l_rc%notfound then
EXIT ;
end if;
FETCH l_rc
INTO l_xml;
update hosp set transmit_date = sysdate;
end loop;
CLOSE l_rc;
The above query returns all items in the table....I am trying to limit the number of records returned based on limit I pass...If the user enters 2, only two items from the node has to be returned. I am not having a clue on how to do this. It would be great if any one can help me...

Thank you both for the replies. I am able to get the data based on the limit I pass...I have another question.
Once the xml doc result is returned or once the select operation is performed and cursor data is fetched into a xmltype variable, I am updating a table's data with the current date...But I have to update the table based on the form_seq_no in the result xml doc...If the result set has three records, then it would have three different form_seq_no. Right now I am doing like below
SELECT XMLELEMENT("form",
xmlagg(xmlelement("item",
XMLFOREST(form_seq_no "form_seq_no",
patientid AS "patientid",
facilityid AS "facilityid" ))))
INTO l_xml
from (SELECT
e.form_seq_no,
e.patientid,
e.facilityid
FROM hosp e
ORDER BY e.form_seq_no
WHERE ROWNUM < p_num_of_rows;
I am using a cursor like below to get the data
OPEN l_rc FOR xml_data;
LOOP
if l_rc%notfound then
EXIT ;
end if;
FETCH l_rc
INTO l_xml;
This is the update I am doing, based on the result set I pasted below....But I get an error that extractValue can return only one child...I am at loss to know how to loop through the result set and perform the update...
update hosp set transmit_date = sysdate where form_seq_no = extractValues(l_xml, 'form/item/form_seq_no);
end loop;
CLOSE l_rc;
If I give rownum <3 , I get 3 rows, the result set might look like as follows:
<form>
<item>
<form_seq_no>1</form_inst_seq_no>
<patientid>21</patientid>
<facilityid>23</facilityid>
</item>
<item>
<form_seq_no>2</form_inst_seq_no>
<patientid>212</patientid>
<facilityid>233</facilityid>
</item>
<item>
<form_seq_no>3</form_inst_seq_no>
<patientid>213</patientid>
<facilityid>234</facilityid>
</item>
I am new to this xml and xml manipulation in oracle...What are the concepts I would have to know in order to achieve my task above? And Right now I have this book called "Oracle Database 11g The Complete Reference" by Kevin Loney, but I neither find any elaborate explanations nor examples. What other books would anyone suggest to learn more on oracle and pl/sql.
Thanks a lot in advance.

Similar Messages

  • Looping through XML tree

    Hi All,
    I need help in retrieving the values of nodes in a XML tree
    If I have a xml document like
    <form>
    <item>
    <form_seq_no>1</form_inst_seq_no>
    <patientid>21</patientid>
    <facilityid>23</facilityid>
    </item>
    <item>
    <form_seq_no>2</form_inst_seq_no>
    <patientid>212</patientid>
    <facilityid>233</facilityid>
    </item>
    <item>
    <form_seq_no>3</form_inst_seq_no>
    <patientid>213</patientid>
    <facilityid>234</facilityid>
    </item>
    How can I get the values of form_Seq_no node?
    I want to loop for all the nodes so that I can update a table for every form_seq_no....
    Thanks....

    Why did you open a new thread where the problem seems to be exactly the same as the one from your Re: Looping through XML Items?
    In particular what is wrong with the solution given Re: Looping through XML Items?

  • Loop through all items in all data blocks?

    Is there a way to loop through every item in every data block and set the property of a format mask?

    I do not know what error it is, only that an on-error trigger fires.
    I found out one thing I was definitely doing wrong, using nextblock, nextitem properties at the wrong level.
    DECLARE
         v_firstblock VARCHAR2(50);
         v_currentblock VARCHAR2(50);
         v_firstitem VARCHAR2(50);
         v_currentitem VARCHAR2(50);
         v_counter NUMBER :=0;
         v_counter2 NUMBER :=0;
    begin
       v_firstblock := get_form_property(:System.Current_Form,first_block);
       v_currentblock:= get_block_property(v_firstblock,nextblock);
       MESSAGE(v_firstblock||v_currentblock);
         LOOP
              v_counter := v_counter +1;
              IF (v_counter >10) THEN
                   exit;
              END IF;
              IF (v_currentblock = v_firstblock) THEN
                             exit;
           ELSE
                   v_firstitem :=  get_block_property(v_firstblock,first_item);
                        IF (lower(GET_ITEM_PROPERTY(v_firstitem,format_mask))=lower('mm-dd-yyyy')) THEN
                                       SET_ITEM_PROPERTY(v_firstitem,format_mask,'DD-MON-YYYY');
                        END IF;
                   v_currentitem :=  get_block_property(v_firstblock,first_item);
                   v_currentblock:= get_block_property(v_currentblock,nextblock);
                   GO_BLOCK(v_currentblock);
                        LOOP
                             v_counter2 := v_counter2 +1;
                             IF (v_counter2>15) THEN
                                  exit;
                             END IF;
                             v_currentitem:= get_item_property(v_currentitem,nextitem);
                             MESSAGE(v_counter||v_firstblock||v_currentblock||v_firstitem||v_currentitem||v_counter2);
                             IF (v_currentitem <> v_firstitem) THEN
                                  IF (lower(GET_ITEM_PROPERTY(v_currentitem,format_mask))=lower('mm-dd-yyyy')) THEN
                                       SET_ITEM_PROPERTY(v_currentitem,format_mask,'DD-MON-YYYY');
                                  END IF;
                             ELSE
                                  exit;
                             END IF;
                        END LOOP;
               END IF;
      END LOOP;
         end;Here is updated new code. I am currently trying to debug it, it has crashed my form on the server when tied to a button press.
    EDIT: So far I have found that it infinitely loops through the first 3 items and a null item in the first block. Still looking into why...
    EDIT: Some code changes to temporarily stop infinite loop and make v_currentblock actually change. Still loops through same 3 items in the first data block even though v_currentblock changes.
    Edited by: 878576 on Oct 21, 2011 12:46 PM

  • Help looping through page items

    Hello,
    I'm new to InDesign scripting and I need a way to programmatically loop through the items on a page of a document and get all of the text frame IDs (Using javascript). Once I find a match of the text frame I am looking for, I will need to update its contents. Is there an easy way to do this?
    Thanks in advance!
    - Lloyd

    Hey!
    var myTextFrames = app.activeDocument.textFrames;
    var myTextFramesNo = myTextFrames.length;
    Now myTextFramesNo holds number of text frames in document and myTextFrames holds text frame objects. Now you can run through text frames and set contents for each of them like this:
    myTextFrames[0].contents = "My Frame Contents";
    That's for start
    tomaxxi
    http://indisnip.wordpress.com/

  • Looping through xml in cfscript

    Ok, I can loop through xml to get the value of any tag and
    output it to a variable. But the problem for me is getting the
    child tags of a specific tag to loop out grouped together. For
    instance, below I would want to group the xml like this.
    Year: 90
    Employer: Bank
    Wages: 2000.00
    Year: 90
    Employer: Gas Station
    Wages: 1000.00
    Ok, I can loop through xml to get the value of any tag and
    output it to a variable. But the problem for me is getting the
    child tags of a specific tag to loop out grouped together. For
    instance, below I would want to group the xml like this.
    Year: 91
    Employer: Bank
    Wages: 2500.00
    Year: 91
    Employer: Gas Station
    Wages: 1500.00
    <year value="90">
    <employer name="bank">
    <wages>2000.00</wages>
    </employer>
    <employer name="gas station">
    <wages>1000.00</wages>
    </employer>
    </year>
    <year value="91">
    <employer name="bank">
    <wages>2500.00</wages>
    </employer>
    <employer name="gas station">
    <wages>1500.00</wages>
    </employer>
    </year>
    Thanks in advanced,
    Anthony

    It will always be sorted by year and by employer. I was just
    trying to get the basic concept of the looping and would figure the
    rest out myself. But I would want it to look like this.
    Employer: Bank
    Year: 90 Wages: 2000.00
    Year: 91 Wages: 2500.00
    Employer: Gas Station
    Year: Wages: 1000.00
    Year: Wages: 1500.00
    Thanks in advance.

  • How to loop through XML data in a table of XMLType?

    Hi,
    I am failry new to xml document processing in Oracle using PL/SQL.
    My DB version: Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
    I have successfully loaded an xml document into a table using the following two statements:
    1) CREATE TABLE mytable2 OF XMLType;
    2) INSERT INTO mytable2 VALUES (XMLType(bfilename('IMAGE_FILE_LOC', 'IFTDISB20100330172157C002.xml'), nls_charset_id('AL32UTF8')));
    Now I need to traverse through the various nodes within the xml document and extract values of elements of each node. The question I have is:
    How do I loop through a node? A VALID record is enclosed within the <checkItem> </checkItem> tags.
    Here is a snippet of the data in that xml document:
    ++++++++++++++++++++++++++++++++++++++++++++++++
    <?xml version="1.0" encoding="UTF-8"?>
    <bdiData>
    <documentControlInfo>
    <documentInfo>
    <docDescription>Check images and data for Test Company, account number 1234567890</docDescription>
    <docID>
    <ID>20100330172157</ID>
    </docID>
    <docModifier>Test Company</docModifier>
    <docCreateDate>2010-03-30</docCreateDate>
    <docCreateTime>17:21:57-0700</docCreateTime>
    <standardVersion>1.0</standardVersion>
    <testIndicator>0</testIndicator>
    <resendIndicator>0</resendIndicator>
    </documentInfo>
    <sourceInfo>
    <sourceName>The Bank IFT</sourceName>
    <sourceID>
    <idOther>TheBankIFT</idOther>
    </sourceID>
    </sourceInfo>
    <destinationInfo>
    <destinationName>Test Company</destinationName>
    <destinationID>
    <idOther>FEI3592</idOther>
    </destinationID>
    </destinationInfo>
    </documentControlInfo>
    <checkItemCollection>
    <collectionInfo>
    <description>Items</description>
    <ID>1269994919135</ID>
    <Classification>
    <classification>Items</classification>
    </Classification>
    </collectionInfo>
    <checkItemBatch>
    <checkItemBatchInfo>
    <description>Paid Checks</description>
    <ID>1269994919135</ID>
    <Classification>
    <classification>Paid Checks</classification>
    </Classification>
    </checkItemBatchInfo>
    <checkItem>
    <checkItemType>check</checkItemType>
    <checkAmount>86468</checkAmount>
    <postingInfo>
    <date>2010-03-29</date>
    <RT>10700543</RT>
    <accountNumber>1234567890</accountNumber>
    <seqNum>009906631032</seqNum>
    <trancode>001051</trancode>
    <amount>86468</amount>
    <serialNumber>300040647</serialNumber>
    </postingInfo>
    <totalImageViewsDelivered>2</totalImageViewsDelivered>
    <imageView>
    <imageIndicator>Actual Item Image Present</imageIndicator>
    <imageViewInfo>
    <Format>
    <Baseline>TIF</Baseline>
    </Format>
    <Compression>
    <Baseline>CCITT</Baseline>
    </Compression>
    <ViewSide>Front</ViewSide>
    <imageViewLocator>
    <imageRefKey>201003260000738400851844567205_Front.TIF</imageRefKey>
    <imageFileLocator>IFTDISB20100330172157M002.zip</imageFileLocator>
    </imageViewLocator>
    </imageViewInfo>
    <imageViewInfo>
    <Format>
    <Baseline>TIF</Baseline>
    </Format>
    <Compression>
    <Baseline>CCITT</Baseline>
    </Compression>
    <ViewSide>Rear</ViewSide>
    <imageViewLocator>
    <imageRefKey>201003260000738400851844567205_Rear.TIF</imageRefKey>
    <imageFileLocator>IFTDISB20100330172157M002.zip</imageFileLocator>
    </imageViewLocator>
    </imageViewInfo>
    </imageView>
    </checkItem>
    <checkItem>
    <checkItemType>check</checkItemType>
    <checkAmount>045</checkAmount>
    <postingInfo>
    <date>2010-03-29</date>
    <RT>10700543</RT>
    <accountNumber>1234567890</accountNumber>
    <seqNum>008518967429</seqNum>
    <trancode>001051</trancode>
    <amount>045</amount>
    <serialNumber>200244935</serialNumber>
    </postingInfo>
    <totalImageViewsDelivered>2</totalImageViewsDelivered>
    <imageView>
    <imageIndicator>Actual Item Image Present</imageIndicator>
    <imageViewInfo>
    <Format>
    <Baseline>TIF</Baseline>
    </Format>
    <Compression>
    <Baseline>CCITT</Baseline>
    </Compression>
    <ViewSide>Front</ViewSide>
    <imageViewLocator>
    <imageRefKey>201003290000713900851896742901_Front.TIF</imageRefKey>
    <imageFileLocator>IFTDISB20100330172157M002.zip</imageFileLocator>
    </imageViewLocator>
    </imageViewInfo>
    <imageViewInfo>
    <Format>
    <Baseline>TIF</Baseline>
    </Format>
    <Compression>
    <Baseline>CCITT</Baseline>
    </Compression>
    <ViewSide>Rear</ViewSide>
    <imageViewLocator>
    <imageRefKey>201003290000713900851896742901_Rear.TIF</imageRefKey>
    <imageFileLocator>IFTDISB20100330172157M002.zip</imageFileLocator>
    </imageViewLocator>
    </imageViewInfo>
    </imageView>
    </checkItem>
    <checkItemBatchSummary>
    <totalItemCount>1028</totalItemCount>
    <totalBatchAmount>61370501</totalBatchAmount>
    <totalBatchImageViewsDelivered>2056</totalBatchImageViewsDelivered>
    </checkItemBatchSummary>
    </checkItemBatch>
    <collectionSummary>
    <totalBatchCount>1</totalBatchCount>
    <totalItemCount>1028</totalItemCount>
    <totalCollectionAmount>61370501</totalCollectionAmount>
    <totalCollectionImageViewsDelivered>2056</totalCollectionImageViewsDelivered>
    </collectionSummary>
    </checkItemCollection>
    <documentSummaryInfo>
    <totalCollectionCount>1</totalCollectionCount>
    <totalBatchCount>1</totalBatchCount>
    <totalItemCount>1028</totalItemCount>
    <totalDocumentAmount>61370501</totalDocumentAmount>
    <totalDocumentImageViewsDelivered>2056</totalDocumentImageViewsDelivered>
    </documentSummaryInfo>
    </bdiData>
    ++++++++++++++++++++++++++++++++++++++++++++++++
    Any ideas and or suggestions will be greatly appreciated.
    Cheers!
    Edited by: user12021655 on Aug 3, 2010 1:25 PM

    I really need to update my blog to get the example you are looking for posted. I did a quick search on the forums for XMLTable and found a good example at {message:id=4325701}. You will want to use OBJECT_VALUE in the PASSING clause where you need to reference the column in your table.
    Note: See the FAQ in the upper right for how to use the tag to wrap objects to retain formatting.  Also your XML is missing closing nodes.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Loop through XML

    I am looking for an example of how to loop through an xml structure, preferrably in VBScript, but I will take a Javascript example and try to figure out how to adapt it.
    Is a FOR EACH loop possible? In normal VBScript you can do something like this...
    ‘strQuery = “/ProfilesInfo/Profiles/ProfileInfo/Profile/Fields/Field [Name='ProfileUri' or Name= 'Age'] /(Name|Value)”
    Set colNodes = xmlDoc.selectNodes( strQuery )
    If colNodes.length>0 Then
    For Each objNode in colNodes
    Print objNode.nodeName & “: ” & objNode.text
    Next
    is it possible to do something like this with XML? Maybe something like
    For each node in myDocument.XMLElements.Item(1)
         {do something}
    Next
    If there is a better way, and I am sure there is, I'll take an example of that instead. 
    I am sure there is probably a way to do it with XPath, but I haven't been able to find any examples of using XPath with VBScript. 
    If anyone has an example of how to use XPath with VBScript I would greatly appreciate it.
    Thank you

    Kasyan, thank you for the reply.  I looked at that part in the book and I have tried using the example code, but I am having difficulty in understanding how it is being used, maybe you, or someone can help to explain it. 
    So in an example like this:
    Class ProcessChildrenRule
         Public Property Get name
              name = "ProcessChildrenRule"
         End Property
         Public Property Get xpath
              xpath = "//XMLElement"
         End Property
         Public Function apply(myXMLElement, myRuleProcessor)
              glueCode_processChildren(myRuleProcessor)
              With myXMLElement
                   myXMLElement.XMLattributes.Item(1).Value
                   myStory.InsertionPoints.Item(-1).Contents =
                   .XMLAttributes.Item(1).Value & vbCr
              End With
         apply = false
         End Function
    End Class
    There are 5 things that I am not understanding. 
    1.  How is "xpath" being used?  I don't see another occurance of it other than when the variable xpath is set.
    2.  How is name being used?  I don't see another occurance of it other than when the variable name is set.
    3.  Why is "Public Function apply" created in each class?  In the examples in the book, that function exists in each Class.  Why not just create the function outside of the class and call it from inside the class?
    4. Where is the "apply" function being called from? It doesn't get called from inside or outside the class on the example pages anywhere?
    5. Where are the values of myXMLElement and myRuleProcessor being set before they are used in the function?
    Even in the examples you gave, once I set the xpath value, what do I do with it after that?  How do I write out the value of what I am searching for with the xpath?
    So going back to my original question, if I set xpath = "/devices/device", how do I loop through each "device" node and write them out?  That is where it is breaking down for me.  I haven't seen any examples in the book or in the downloaded example code that show how to do that. 

  • Looping Through XML Maybe .. ?

    Hey Guys,
    I'm sure this has been covered before, but I can't adequately
    define it and find it from searching. What I have is the following
    XML:
    <item>
    <xmlName>
    <xmlPrice>
    <xmlDesc>
    </item>
    The XML Description might have anywhere from 1-5 paragraphs
    of text in it. How can I break this up to display with <p>
    tags around each paragraph? If I could have each paragraph in an
    <xmlDesc> block, I could just have 1-5 of those blocks for
    each paragraph in the XML. Of course I can't put tags in the XML,
    or I could just store them all in one tag.
    So what about looping? I'm guessing I'll have to somehow set
    the XML up so I can loop through and pick up the 1-5 paragraphs of
    text (xmlDesc tags) somehow, right?
    Any suggestions would be greatly appreciated.
    Thanks!

    Use a CDATA, then you can encapsulate whatever inside a XML
    tag. Everything inside a CDATA is ignorred by the XML parser, but
    not the HTML parser.
    <xml>
    <item>
    <desc>
    <![CDATA[
    <p>Write whatever in here and they lived happily ever
    after</p>
    <p>Of course, this is just an example.</p>
    <p>Taking this a step further, you could even hardcode
    an image into this</p>
    ]]>
    </desc>
    </item>
    </xml>

  • Looping through inbox items on timer event is really slow...?

    Hi,
    I have an issue with a email sync event that I am running.  Essentially, I am given a date (the received date of the last email synced) via another process and then need to return all the emails in the user's inbox the where receivedDate > this given
    date.
    I have a timer object than triggers my sync event every 15 mins.  I also have a button that allows the user to manually activate the sync - this basically changes the timer to 3 secs and so it fires the sync event.
    If the sync event is fired manually as per above, it loops through everything quite quickly (~12,000 emails in 30 secs) and I can stored the sender/recipient and received time data I require from these in a list of objects, which I sync later on in a background
    process.  During this loop the main UI freezes up, which is fine since I show a progress bar so the user knows how long they need to wait, and a large sync like this should only occur on their first sync theoretically.  If the first sync event is
    fired without the manual input - so still called from the same timer event, but just on the normal 15 min event, not the shortened 3 sec one - then it runs differently.  The sync takes a lot lot longer, and the UI doesn't freeze up.
    I presume this might be because it is fired slightly differently and does not hog up the main thread, but rather shares it with normal Outlook operations.  Maybe the operations are being run on a background thread and then keep having to jump into the
    main thread to access the email items...?  Either way, I'm not quite sure how this is happening since the only difference is the user pressing a button that changes the timer.interval.  The code that is run is the same, and the button press doesn't
    trigger the actual sync itself.
    Is there a way I can force this first sync to always run solely in the main thread, it can freeze up Outlook and show the progress bar until it is done?  Ideally any subsequent syncs would then be run with no progress bar and no freezing up of the UI.
    Many thanks,
    Tom

    Hello Tom,
    > Maybe the operations are being run on a background thread and then keep having to jump into the main thread to access the email items...?
    You shouldn't use another threads when dealing with the Outlook object model. Office applications use the single threaded apartment (STA) model and don't support multithreading. All calls made from another threads are marshalled by Outlook to the main
    thread. However, you can use a low-level code (Extended MAPI) to access the data from secondary threads. For example, you can use Redemption which is based on Extended MAPI.
    >  it loops through everything quite quickly (~12,000 emails in 30 secs)
    Instead of looping over all items in the folder I'd recommend using the
    Find/FindNext
    or
    Restrict methods of the Items class. You can read more about them in the following articles:
    How To: Use Find and FindNext methods to retrieve Outlook mail items from a folder (C#, VB.NET)
    How To: Use Restrict method to retrieve Outlook mail items from a folder
    You can use the System.Windows.Forms.Timer class which uses the main thread for invoking the Tick event. The .NET
    Framework Class Library provides three different timer classes: System.Windows.Forms.Timer, System.Timers.Timer, and System.Threading.Timer. Each of these classes has been designed and optimized for use in different situations. The Comparing
    the Timer Classes in the .NET Framework Class Library article examines the three timer classes and helps you gain an understanding of how and when each class should be used.
    Also you may find the
    AdvancedSearch method of the Application class helpful. Pay special attention to the fact that the search is performed in another thread. You don’t need to run another thread manually since the
    AdvancedSearch method runs it automatically in the background. See
    Advanced search in Outlook programmatically: C#, VB.NET for more information.

  • Does anyone know a way to programatically loop through the items in the document library

    A lot of the funcations like deleteSymbol and updateSymbol depend on which items are "selected" in the library panel.
    Is there a way to programatically access these selections?
    or
    Loop through the library?
    or
    Set selections?

    Yup, I've asked for an API to access the selection in those panels for years, to no avail.
    Note that you can loop through layers, frames and pages, but you can't tell what the user has selected in the actual panel UI.  Also, you can't find out which symbols are currently used in the document.  Nor can you programmatically insert a rich symbol into the document and have it maintain its "richness".

  • How to loop through xml records from file without ROW , /ROW tags?

    I am using dbms_XMLSave.insertXML procedure to insert xml formated record from file. MY xmlformated records does not have open and close ROW tags. I have multiple records in the file.How can I loop through without <ROW>,</ROW> tags?

    I am using dbms_XMLSave.insertXML procedure to insert xml formated record from file. MY xmlformated records does not have open and close ROW tags. I have multiple records in the file.How can I loop through without <ROW>,</ROW> tags?

  • Oracle Looping through XML nodes

    Hi,
    I have this XML which i m getting as response from a webservice. i need to loop through nodes and i m not sure how to go about it. i have done example using dbms_xmldom but i m literally stuck. this is the xml here i need to loop through
    statuslognotes for one enquiry, there may be multiple statuslognotes and need to insert into database....
    i also need to check for multiple updatedenquiry and if thats got statuslognotes....i hope you get me.
    <ProcessOperationsResult xmlns="http://www.abc.co.uk/schema/am/connector/webservice" >
    <Response SchemaVersion="1.4" xmlns="" >
    <OperationResponse>
    <GetEnquiryStatusChangesResponse>
    <UpdatedEnquiry>
    <EnquiryNumber>104</EnquiryNumber>
    <ExternalSystemNumber>1</ExternalSystemNumber>
    <ExternalSystemReference>195</ExternalSystemReference>
    <EnquiryStatusLog>
    <EnquiryStatusCode>1224</EnquiryStatusCode>
    <EnquiryStatusName>Cancelled By User</EnquiryStatusName>
    <AssignedOfficerCode>BBB</AssignedOfficerCode>
    <AssignedOfficerName>Testing</AssignedOfficerName>
    <LoggedTime>2007-12-11T14:44:53</LoggedTime>
    <LogEffectiveTime>2007-12-11T14:44:52</LogEffectiveTime>
    <StatusFollowUpTime>2007-12-11T14:44:52</StatusFollowUpTime>
    <LoggedByUserName>System Supervisor</LoggedByUserName>
    <LoggedByUserId>AAA</LoggedByUserId>
    </EnquiryStatusLog>
    <EnquiryStatusLog>
    <EnquiryStatusCode>1225</EnquiryStatusCode>
    <EnquiryStatusName>Cancelled By User</EnquiryStatusName>
    <AssignedOfficerCode>DEF</AssignedOfficerCode>
    <AssignedOfficerName>Srinivas</AssignedOfficerName>
    <LoggedTime>2007-12-11T14:44:53</LoggedTime>
    <LogEffectiveTime>2007-12-11T14:44:52</LogEffectiveTime>
    <StatusFollowUpTime>2007-12-11T14:44:52</StatusFollowUpTime>
    <LoggedByUserName>System Supervisor</LoggedByUserName>
    <LoggedByUserId>AAA</LoggedByUserId>
    </EnquiryStatusLog>
    </UpdatedEnquiry>
    <UpdatedEnquiry>
    <EnquiryNumber>105</EnquiryNumber>
    <ExternalSystemNumber>1</ExternalSystemNumber>
    <ExternalSystemReference>196</ExternalSystemReference>
    <EnquiryStatusLog>
    <EnquiryStatusCode>1226</EnquiryStatusCode>
    <EnquiryStatusName>Cancelled By User</EnquiryStatusName>
    <AssignedOfficerCode>Test</AssignedOfficerCode>
    <AssignedOfficerName>SS</AssignedOfficerName>
    <LoggedTime>2007-12-11T14:44:53</LoggedTime>
    <LogEffectiveTime>2007-12-11T14:44:52</LogEffectiveTime>
    <StatusFollowUpTime>2007-12-11T14:44:52</StatusFollowUpTime>
    <LoggedByUserName>System Supervisor</LoggedByUserName>
    <LoggedByUserId>BS</LoggedByUserId>
    </EnquiryStatusLog>
    </UpdatedEnquiry>
    </GetEnquiryStatusChangesResponse>
    </OperationResponse>
    </Response>
    </ProcessOperationsResult>
    Any help appreciated....as i m new to this XPATH stuff in oracle.
    Cheers
    S

    hi,
    i have written this stored procedure, but i m sure this is not perfect. i want someone to help me out with this.
    CREATE OR REPLACE procedure ParseXML as
    l_xml XMLTYPE;
    l_value VARCHAR2(10);
    SCHEMALIST_DOM DBMS_XMLDOM.DOMDOCUMENT;
    SCHEMA_NODELIST DBMS_XMLDOM.DOMNODELIST;
    SCHEMA_NODELIST_SUB DBMS_XMLDOM.DOMNODELIST;
    SCHEMA_NODE DBMS_XMLDOM.DOMNODE;
    SCHEMA_sub_XPATH VARCHAR2(256);
    SCHEMA_XPATH VARCHAR2(256);
    CHILD_XPATH VARCHAR2(256);
    SOURCE_PATH VARCHAR2(256);
    XPATH_INDEX number(2);
    XPATH_sub_INDEX number(2);
    NODE_VALUE VARCHAR2(256);
    Statcode VARCHAR2(256);
    Statname VARCHAR2(256);
    Officer VARCHAR2(256);
    BEGIN
    l_xml := XMLTYPE.createXML('<ProcessOperationsResult xmlns="http://www.abc.co.uk/schema/am/connector/webservice">
    <Response SchemaVersion="1.4" xmlns="">
    <OperationResponse>
    <GetEnquiryStatusChangesResponse>
    <UpdatedEnquiry>
    <EnquiryNumber>104</EnquiryNumber>
    <ExternalSystemNumber>1</ExternalSystemNumber>
    <ExternalSystemReference>195</ExternalSystemReference>
    <EnquiryStatusLog>
    <EnquiryStatusCode>1224</EnquiryStatusCode>
    <EnquiryStatusName>Cancelled By User</EnquiryStatusName>
    <AssignedOfficerCode>TEST</AssignedOfficerCode>
    <AssignedOfficerName>test</AssignedOfficerName>
    <LoggedTime>2007-12-11T14:44:53</LoggedTime>
    <LogEffectiveTime>2007-12-11T14:44:52</LogEffectiveTime>
    <StatusFollowUpTime>2007-12-11T14:44:52</StatusFollowUpTime>
    <LoggedByUserName>System Supervisor</LoggedByUserName>
    <LoggedByUserId>BS</LoggedByUserId>
    </EnquiryStatusLog>
    <EnquiryStatusLog>
    <EnquiryStatusCode>1225</EnquiryStatusCode>
    <EnquiryStatusName>Cancelled By User</EnquiryStatusName>
    <AssignedOfficerCode>DEF</AssignedOfficerCode>
    <AssignedOfficerName>SSi</AssignedOfficerName>
    <LoggedTime>2007-12-11T14:44:53</LoggedTime>
    <LogEffectiveTime>2007-12-11T14:44:52</LogEffectiveTime>
    <StatusFollowUpTime>2007-12-11T14:44:52</StatusFollowUpTime>
    <LoggedByUserName>System Supervisor</LoggedByUserName>
    <LoggedByUserId>SBS</LoggedByUserId>
    </EnquiryStatusLog>
    </UpdatedEnquiry>
    <UpdatedEnquiry>
    <EnquiryNumber>105</EnquiryNumber>
    <ExternalSystemNumber>1</ExternalSystemNumber>
    <ExternalSystemReference>196</ExternalSystemReference>
    <EnquiryStatusLog>
    <EnquiryStatusCode>1226</EnquiryStatusCode>
    <EnquiryStatusName>Cancelled By User</EnquiryStatusName>
    <AssignedOfficerCode>TEST</AssignedOfficerCode>
    <AssignedOfficerName>test</AssignedOfficerName>
    <LoggedTime>2007-12-11T14:44:53</LoggedTime>
    <LogEffectiveTime>2007-12-11T14:44:52</LogEffectiveTime>
    <StatusFollowUpTime>2007-12-11T14:44:52</StatusFollowUpTime>
    <LoggedByUserName>System Supervisor</LoggedByUserName>
    <LoggedByUserId>SBS</LoggedByUserId>
    </EnquiryStatusLog>
    </UpdatedEnquiry>
    </GetEnquiryStatusChangesResponse>
    </OperationResponse>
    </Response>
    </ProcessOperationsResult>');
    SCHEMALIST_DOM := DBMS_XMLDOM.newDOMDocument(L_XML);
    SCHEMA_NODELIST := DBMS_XMLDOM.GETELEMENTSBYTAGNAME(SCHEMALIST_DOM,'GetEnquiryStatusChangesResponse');
    SCHEMA_NODELIST_SUB := DBMS_XMLDOM.GETELEMENTSBYTAGNAME(SCHEMALIST_DOM,'/UpdatedEnquiry/EnquiryStatusLog');
    FOR i in 0 .. (DBMS_XMLDOM.GETLENGTH(SCHEMA_NODELIST) - 1) LOOP
    XPATH_INDEX := i+1;
    FOR j in 0 .. (DBMS_XMLDOM.GETLENGTH(SCHEMA_NODELIST_SUB) - 1) LOOP
    XPATH_SUB_INDEX := J+1;
    SCHEMA_SUB_XPATH := '/GetEnquiryStatusChangesResponse/UpdatedEnquiry[' || XPATH_INDEX || ']/EnquiryStatusLog[' || XPATH_sub_INDEX || ']/';
    --dbms_output.put_line(SCHEMA_SUB_XPATH);
    CHILD_XPATH := SCHEMA_SUB_XPATH || 'EnquiryStatusCode/text()';
    dbms_output.put_line('child path text ' || child_XPATH);
    DBMS_XSLPROCESSOR.VALUEOF(DBMS_XMLDOM.MAKENODE(SCHEMALIST_DOM),CHILD_XPATH, Statcode);
    CHILD_XPATH := SCHEMA_SUB_XPATH || 'EnquiryStatusName/text()';
    DBMS_XSLPROCESSOR.VALUEOF(DBMS_XMLDOM.MAKENODE(SCHEMALIST_DOM),CHILD_XPATH, Statname);
    CHILD_XPATH := SCHEMA_SUB_XPATH || 'AssignedOfficerCode/text()';
    DBMS_XSLPROCESSOR.VALUEOF(DBMS_XMLDOM.MAKENODE(SCHEMALIST_DOM),CHILD_XPATH, Officer);
    dbms_output.put_line('EnquiryStatusCode => "' || Statcode || '",');
    dbms_output.put_line('EnquiryStatusname => "' || Statname || '",');
    dbms_output.put_line('AssignedOfficerCode => "' || Officer || '",');
    end loop;
    --GetEnquiryStatusChangesResponse/UpdatedEnquiry[2]
    schema_xpath := '/GetEnquiryStatusChangesResponse/UpdatedEnquiry[' || XPATH_INDEX || ']/EnquiryStatusLog['|| XPATH_INDEX || ']/' ;
    CHILD_XPATH := SCHEMA_XPATH || 'EnquiryStatusCode/text()';
    dbms_output.put_line('another node text ' || child_XPATH);
    DBMS_XSLPROCESSOR.VALUEOF(DBMS_XMLDOM.MAKENODE(SCHEMALIST_DOM),CHILD_XPATH, Statcode);
    end loop;
    end;
    Basically i may just get one UpdatedEnquiry record with multiple EnquiryStatusLog (changes),
    I need to get the EnquiryStatusLog nodes and create a insert stmt with the Enquiry Number.
    and if theres multiple <UpdatedEnquiry> nodes, i need the same thing done.
    Hope i make sense here.....
    Can someone help
    Cheers
    S

  • OSB: Looping through XML Structure

    How could I loop through a WHOLE XML structure and check the contents of each node to determine whether it is a dateTime stamp?
    I attempted a for-each loop in OSB but I could not get my expected output
    A sample xml structure may look like this
    <ebo:CreateQuoteEBM >
        <ebo:DataArea>
          <ebo:CreateQuote>
            <ebo:Custom>
              <chubCommon:Quote>
                  <chubCommon:ItemDetail>
                         <chub:Name>Test</chub:Name>
                        <chub:Value>20130527T12:02:13<chub:Value>
                  </chubCommon:ItemDetail>
                  <chubCommon:Reference>
                      <chubCommon:ReferenceQualifier>Bid Submit Date</chubCommon:ReferenceQualifier>
                      <chubCommon:Value>20130527T12:02:13</chubCommon:Value>
                    </chubCommon:Reference>
              </chubCommon:Quote>
            </ebo:Custom>
          </ebo:CreateQuote>
        </ebo:DataArea>
      </ebo:CreateQuoteEBM>
    Bonus: If it is a dateTime stamp convert into a date
    Thanks!

    You can use FLOWR loop to loop though this, and then for each node check if conditon is (fn:data() is true and fn:matches()) to check if the node is of datetime type. fn:data() will give you the if the xml node has some data and then using fn:matches() you can compare it with the datetime pattern, You can use a regex pattern to compare 20130527T12:02:13 . For converting this date use fn:substring() get the data before "T" and use fucntion similar to this functx:mmddyyyy-to-date for converting to date.For converting to date you can also use substring to extract the data from node and then use below fucntion to convert to date.
    declare function functx:date
      ( $year as xs:anyAtomicType ,
      $month as xs:anyAtomicType ,
      $day as xs:anyAtomicType ) as xs:date {
      xs:date(
      concat(
      functx:pad-integer-to-length(xs:integer($year),4),'-',
      functx:pad-integer-to-length(xs:integer($month),2),'-',
      functx:pad-integer-to-length(xs:integer($day),2)))

  • Trouble looping through XML file

    I've got the following code which loops through an XML file. It works when there are multiple devices in the XML file and the COMPUTER node in the script includes [$i] but if only one device is in the network (thus only one in the XML file) then I have to
    remove the [$i]. What am I doing wrong to make it apply to both?
    $i = 0
    foreach ($COMPUTER in $settings.Settings.Setting.COMPUTERS.COMPUTER) {
    # IP for Computer
    $IPADDRESS = $settings.Settings.Setting.COMPUTERS.COMPUTER[$i].COMPUTERIP
    # Username for Computer
    $USERNAME = $settings.Settings.Setting.COMPUTERS.COMPUTER[$i].USERNAME
    # Credentials file
    $CREDFILE = $settings.Settings.Setting.COMPUTERS.COMPUTER[$i].CRED
    # Do things here using the variables declared above
    $i= $i+1
    } # Stop looping
    I should point out that I've changed the variable and XML names accordingly but the principle is the same.
    Thanks in advance

    Hi Bobbins,
    no, I just pasted that there so you can copy&paste it to the console and see the results. External XML sources are totally valid.
    To apply this to your initial script example, replace all instances of ...
    $settings.Settings.Setting.COMPUTERS.COMPUTER[$i]
    ... with ...
    $COMPUTER
    Cheers,
    Fred
    There's no place like 127.0.0.1

  • Looping through XML

    I am new at working with XML in flash (or XML with anything
    for that matter)
    I want to loop through the following schema and have a list
    of all employees and attached specifics can anyone point me in the
    right direction?

    First, depends on what version of actionscript you are using.
    If you are already using AS3, xml parsing is MUCH easier.
    If you are still using AS2, you will need to write a parser.
    Take a look at XPath's API. You can loop through multilevel XML
    using some of its functions. But... get ready to code! :)

Maybe you are looking for

  • Loading VRML 1.0 files in Java 3D

    Hi all, Does anyone have a successful experience loading VRML 1.0 file into Java 3D as a scene graph? While I think it's too complicated to write my own loader, is there any existing loader available for this task? I've tried 2 VRML loaders, but neit

  • Powerbook TV question as well but a little different!?!?!

    does anyone know how to record from TV to powerbook. like say i wanted to record my halo games. i know how to use my TV as another display but i mean its not like i cant display my XBOX and my powerbook at the same time. so i guess i need some sort o

  • Can't get this html to work in safari

    I want to put a boombox on one of my html pages. I have a program from Coffeecup that does this. It changes mp3 files into swf and then makes a flash player that plays the pieces. It there fore makes an html file with the flash embeded, as well as a

  • Creating a new table similar to an existing one

    Hi, I need to implement a stored procedure with the follwing signature (simplified) CREATE_TABLE_AS(p_NewTableName , p_OrigTableName , p_Col1, p_Col2, p_Col3) It should do the following: Creating a new, empty table with name p_newTableName. The new t

  • "Audio Output" section is disabled

    Hello, I have the question. I made IO plugin. It supports audio and video. It works well in CS4. I have the problem when moving from CS4 to CS5. Combo boxes (frequency, bit per sample, channels) are disables in "Output Module Settings" dialog when "A