Grabbing the elements from the XML root node

Hello,  I haven't worked with XML in over a year and I didn't use it much then.  I'm trying to remember the best way to get the values from the root note (not child nodes).
For instance, in the following xml, I want the timestamp and the messageID from stumessages.
I can't recall if you are supposed to use xmlsearch or something else.  I know how to grab the child nodes (for some reason, that part was easier to recall).
<cfsavecontent variable="XMLFile"><?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE stuMessages SYSTEM "http://cody.glpconnect.com/DTD/StuMessage_Rev6.dtd">
<stuMessages timeStamp="14/05/2012 08:02:11 GMT" messageID="9768c7201b6f100585fbfa3243489116">
     <stuMessage>
          <esn>0-999999</esn>
          <unixTime>1336982529</unixTime>
          <gps>N</gps>
          <payload length="9" source="pc" encoding="hex">0x3530E2B18801031200</payload>
     </stuMessage>
</stuMessages>
</cfsavecontent>
<!--- Set the XML to a XML parsed variable we can use --->
<cfset MyXMLDoc = xmlParse(XMLFile) />
<!--- Dump the XML --->
<h2>Dump</h2>
<!--- <cfdump var="#MyXMLDoc#"> --->
<!--- Get all Message Nodes --->
<cfset messageNodes = xmlSearch(MyXMLDoc,'/stuMessages/stuMessage')>
<cfoutput>
    <h2>Message Nodes</h2>
    <cfloop from="1" to="#arraylen(messageNodes)#" index="i">
        <!--- The array contents need to parsed so you can easily get at the child nodes children and attributes. --->
        <cfset messageXML = xmlparse(messageNodes[i]) />
        <b>esn:</b> #messageXML.stuMessage.esn.xmltext#<br>
        <b>unixTime:</b> #messageXML.stuMessage.unixTime.xmlText#<br>
        <b>gps:</b> #messageXML.stuMessage.gps.xmlText#<br>
        <b>payload:</b> #messageXML.stuMessage.payload.xmlText#<br><br>
    </cfloop>
</cfoutput>
Best regards
KR

Hello,
I figured it out.
I figured I would update my post in case anyone else was curious.
I just need to add the following two lines into the code to expose the elements of the root node.
    <cfset timeStamp = MyXMLDoc.stuMessages.XmlAttributes.timeStamp>
    <cfset messageid = MyXMLDoc.stuMessages.XmlAttributes.messageID>
The full code follows
<!--- Set the XML to a XML parsed variable we can use --->
<cfset MyXMLDoc = xmlParse(XMLFile) />
<!--- Dump the XML --->
<h2>Dump</h2>
<!--- <cfdump var="#MyXMLDoc#"> --->
<!--- Get all Message Nodes --->
<cfset messageNodes = xmlSearch(MyXMLDoc,'/stuMessages/stuMessage')>
<cfoutput>
    <cfset timeStamp = MyXMLDoc.stuMessages.XmlAttributes.timeStamp>
    <cfset messageid = MyXMLDoc.stuMessages.XmlAttributes.messageID>
    #timeStamp#<br />
    #messageid#<br />
    <h2>Message Nodes</h2>
    <cfloop from="1" to="#arraylen(messageNodes)#" index="i">
        <!--- The array contents need to parsed so you can easily get at the child nodes children and attributes. --->
        <cfset messageXML = xmlparse(messageNodes[i]) />
        <b>esn:</b> #messageXML.stuMessage.esn.xmltext#<br>
        <b>unixTime:</b> #messageXML.stuMessage.unixTime.xmlText#<br>
        <b>gps:</b> #messageXML.stuMessage.gps.xmlText#<br>
        <b>payload:</b> #messageXML.stuMessage.payload.xmlText#<br><br>
    </cfloop>
</cfoutput>

Similar Messages

  • Kill a thread and remove the element from the vector

    Hi All
    I have attached each Vector element to a thread which I later want to kill and remove that element from the Vector.
    Thread.join(milliseconds) allows this functionality to let the thread die after n milliseconds.
    However, I want to delete this element from the Vector now.
    Can someone please throw some light on this?
    Here the code I have written for this:
    try
         System.out.println(counter);
         int xCoord = generator.irand(25,200);     // X-coord of AP
         int yCoord = generator.irand(25,200);     // Y coord of AP
         listMN.addElement(new MobileNode((int)mnId,new Point2D.Double(xCoord,yCoord)));
         listMNcoords.addElement(new Point2D.Double(xCoord,yCoord));
         for(int i=0;i<vnuBS.returnBSList().size();i++)
              if(vnuBS.returnBSListCoords().get(i).contains(xCoord,yCoord)&&(vnuBS.returnBSList().get(i).getChannelCounter()<=3)&&(vnuBS.returnBSList().get(i).getChannelCounter()>0))
                   double c = exponential() * 10000;
                   long timeToService = (long)c;
                   System.out.println("BS "+vnuBS.returnBSList().get(i).id+" is connected to MN ");
                   vnuBS.returnBSList().get(i).reduceChannelCounter();
                   System.out.println("Channel Counter Value Now: "+vnuBS.returnBSList().get(i).getChannelCounter());
                   mobileNodesThread.addElement(new Thread(listMN.elementAt(mobileNodeCounter)));
                   mobileNodesThread.elementAt(mobileNodeCounter).setName(mobileNodeCounter+"");
                   mobileNodesThread.elementAt(mobileNodeCounter).start();
                   mobileNodesThread.elementAt(mobileNodeCounter).join(100);
    //                              System.out.println("Died");// thread dies after join(t) milliseconds.
                   System.out.println("ListMN getting generated : " + mobileNodesThread.get(mobileNodeCounter));
              else if(vnuBS.returnBSListCoords().get(i).contains(xCoord,yCoord)&&(vnuBS.returnBSList().get(i).getChannelCounter()<=0))
                   listMN.remove(this.listMN.lastElement());                         //dropcall
                   System.out.println("Removed "+mnId);
                   removeCounter++;
                   mnId = mnId--;
                   mobileNodeCounter--;
              mnId = mnId+1;
         Thanks a lot.

    I'm not sure if what you are trying to accomplish is correctly implemented.
    The method join does not kill the thread. It will wait for the specified time for the thread to exit. If you want the thread to run for a specified ammount of time, develop the run method of that thread with that in mind. Do not try to kill it from the outside, but let it terminate itself (gracefull termination).
    Now for your question regarding the vector (you should probably be using ArrayList nowadays): I would implement the observer pattern for this job. Make the threads post an event on the interface when they are done, let the main thread register itself with the threads and synchronize the method that handles the events. In that method you can remove the object from your list.
    I'm not sure if you want to use thread anyhow, could you tell us what it is that you are trying to accomplish?

  • How to get the values of all elements and sub elements from  following xml

    how to get the values of all elements and sub elements from following xml...
    <?xml version="1.0" encoding="UTF-8" ?>
    <List_AML_Finacle xmlns="http://3i-infotech.com/Cust_AML_Finacle.xsd"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://3i-infotech.com/Cust_AML_Finacle.xsd List_AML_Finacle.xsd">
    <TransactionID>TransactionID</TransactionID>
    <Match>
    <Src_Matched_Field>Src_Matched_Field</Src_Matched_Field>
    <List_Matched_Field>
    <FSFM_Matches>
    <NUMBER>NUMBER</NUMBER>
    <TERROR>TERROR</TERROR>
    <TU>TU</TU>
    <NAMEU>NAMEU</NAMEU>
    <DESCRIPT>DESCRIPT</DESCRIPT>
    <KODCR>KODCR</KODCR>
    <KODCN>KODCN</KODCN>
    <AMR>AMR</AMR>
    <ADDRESS>ADDRESS</ADDRESS>
    <SD>SD</SD>
    <RG>RG</RG>
    <ND>ND</ND>
    <VD>VD</VD>
    <GR>GR</GR>
    <YR>YR</YR>
    <MR>MR</MR>
    <CB_DATE>CB_DATE</CB_DATE>
    <CE_DATE>CE_DATE</CE_DATE>
    <DIRECTOR>DIRECTOR</DIRECTOR>
    <FOUNDER>FOUNDER</FOUNDER>
    <TERRTYPE>TERRTYPE</TERRTYPE>
    </FSFM_Matches>
    <OfacMatchDetails>
    <UID>UID</UID>
    <TITLE>TITLE</TITLE>
    <SDNTYPE>SDNTYPE</SDNTYPE>
    <REMARKS>REMARKS</REMARKS>
    <ID_UID>ID_UID</ID_UID>
    <IDTYPE>IDTYPE</IDTYPE>
    <IDNUMBER>IDNUMBER</IDNUMBER>
    <IDCOUNTRY>IDCOUNTRY</IDCOUNTRY>
    <ISSUEDATE>ISSUEDATE</ISSUEDATE>
    <EXPIRATIONDATE>EXPIRATIONDATE</EXPIRATIONDATE>
    <ADDRESS1>ADDRESS1</ADDRESS1>
    <ADDRESS2>ADDRESS2</ADDRESS2>
    <ADDRESS3>ADDRESS3</ADDRESS3>
    <CITY>CITY</CITY>
    <STATEORPROVINCE>STATEORPROVINCE</STATEORPROVINCE>
    <POSTALCODE>POSTALCODE</POSTALCODE>
    <COUNTRY>COUNTRY</COUNTRY>
    </OfacMatchDetails>
    </List_Matched_Field>
    </Match>
    </List_AML_Finacle>

    avoid multi post
    http://forum.java.sun.com/thread.jspa?threadID=5249519

  • Use DOM to get the element value of XML document?

    I can not to use the method getNodeValue to get the element value of XML document. How can I do for it?
    For example, for element
    <address>125 Smith Avenue</address>
    how to get the value "125 Smith Avenue" by using DOM?
    Thanks

    Thanks for all of you.
    The code indicates that I need to get the node by tag name. If I do not know the distribution of the elements and want to traverse all nodes. If the node contains value, I retrieve the value. How to implement the general case.
    For example, my XML file represent a directory hierarchy and looks like
    <root>
    <usr>
    <user>user1
    <file>file1</file>
    <file>file2</file>
    </user>
    <user>user2
    <file>file1</file>
    <file>file2</file>
    <file>file3</file>
    <file>file4</file>
    </user>
    </usr>
    </root>

  • How to get the data from the model node like a table ?

    I want to get the data from the model node  once a record ,and the node  is bound to a internal table in the RFM which I called in the R/3 system. Who can give me some advice to achive it?Thank you!!

    Hi,
    To get the data from the node:
    wdContext.node[your node name].current[node name]_InputElement().get[specific element in the node];
    or you van use:
    wdContext.current[your node]Element().get[your element in the node];
    examples:
    wdContext.nodeZ_Mepro_Po_Detail_Stock_Distri_Input().currentZ_Mepro_Po_Detail_Stock_Distri_InputElement().getUcpd_Flag();
    wdContext.currentT_Delv_ReqsElement().getShelflife();
    regards,

  • Accessibility, exclude UI elements from the Tab-chain

    Hi,
    I have a complex UI which is very uncomfortable to access with the Tab key when using sap-accesssibility=true parameter. The main problem are the many transparent containers, which are necessary to create the refined composition of the UI. They get focused when the Tab key is pressed and this is completely useless. I there a way to exclude UI elements from the Tab-chain?
    Best regards,
    Krasimir

    Hi,
    I have same prolem here.
    In my UI I am using mastercolumn for expand /collapse functionality in parent - child node .
    The problem is the keyboard tab-chain is skipping the master column which makes it a accessibility issue.
    Is there any way we can include/exclude UI elements from tab chain.
    My NWDS version is 7.0.10.

  • Does anyone know how to convert the output from the standard report to xml?

    Does anyone know how to convert the output from the standard SAP report to xml?

    since it a standard report which you cannot modify you can only do the following.
    submit report exporting list to memory
    then
    list from memory and then
    use the returned itab along with CALL TRNSFORMATION key word to convert to xml.
    but this only going to place the whole list content (including data and formating lines,etc) into a xml element and not the actual data alone in the list .

  • How to fetch the data from the table COEP for WBS element,cost center,,,,,?

    Hi,
    I would like to retrive the data from the table COEP ,based on KOKRS,BELNR fields.
    I need the output for Cost centre, cost element, wbs element,net work ,activity.
    These values are storing OBJNR ,OBJNAR_1,OBJNR_2,OBJNR_N3.
    But here always these field are not giving the correct values.
    for example : for one record COST CENTRE vlaue is storing in OBJNR_1 field,
                        for one record COST CENTRE vlaue is storing in OBJNR_2 field,
                       for one record  COST CENTRE vlaue is storing in OBJNR_3 field.
    Here SAP has used a generic approach for this.
    How can I dispaly the values in this case ?
    Thanks and Regards
    Srinivas.N

    Hi,
    I am asking, how can we say OBJNR_1 value alwyas belongs to cost center ?
    USPOB is not filling always.

  • I have elements 12 in Windows 7 but is unable to see mp4 files in the organiser. The sound from the file is there but no image!

    I have elements 12 in Windows 7 but is unable to see mp4 (Canon G16) files in the organiser. The sound from the file is there but no image!
    Other file formats from Canon is no problen. So What to do??
    Roger

    Me again,
    A friend suggested that I do a system restore.
    I did a search for system restore in Windows 7 and got a very intuitive menu.
    I selected an earlier system restore point and executed the restore.
    After the computer restart I reloaded Firefox 5.0 and the Ask.com problem was corrected.
    My friend says this approach may work about 25% of the time to fix this kind of problem. In my case it worked and I am happy.
    Thanks all.
    Richard Ryer

  • Is there a way to remove the index from the XML output?

    Hi,
    It is easy to remove the index from the WebHelp output.
    We also want to remove it from the XML output.
    How do I do that?
    Thanks,
    Rakefet

    @Jeff: In the Single Source Layouts recipe box is a layout for XML. Although, I'm really not sure why folks would use it, other than to possibly export the project data to another system of some sort.
    @Rakefet: One thought is to try creating a new blank Index. Then choose the empty Index when you use XML Output.
    Cheers... Rick

  • Parsing the data from and xml type field

    Hi - I have registered a schema and inserted arecord into the table with the xml type column. Now I want to parse the data from the xmltype field into a relational table. I have been using the following select statement to accomplish this - and it does work if there is data in all the selected fields but when the filed is null then the whole select statement fails and brings back 'no rows returned'.If the value is null I want the select statment to return null. please give any ideas.
    SELECT version,frmd_transaction_date,extractValue(value(b), 'event_update/location')"location",
    extractValue(value(b), 'event_update/sending_system')"sending_system",
    extractValue(value(b), 'event_update/event_identifier')"event_identifier",
    extractValue(value(b), 'event_update/event_link')"event_link",
    extractValue(value(b), 'event_update/organization_code')"organization_code",
    nvl(extractValue(value(c), '/schedule/event_duration_minutes'),'000')"event_minutes"
    FROM fraamed_user.frmd_event_update , TABLE(xmlsequence(extract(xml_event_update, '/event_update')))b,
    TABLE(xmlsequence(extract(xml_event_update, '/event_update/schedule')))c

    ...then I guess you have to rewrite the query.
    Is schedule another xml sequence inside of event_update sequence ?
    If it is not you can try this :
    SELECT version,frmd_transaction_date,extractValue(value(b), '/event_update/location/text()')"location",
    extractValue(value(b), '/event_update/sending_system/text()')"sending_system",
    extractValue(value(b), '/event_update/event_identifier/text()')"event_identifier",
    extractValue(value(b), '/event_update/event_link/text()')"event_link",
    extractValue(value(b), '/event_update/organization_code/text()')"organization_code",
    extractValue(value(b), '/event_update/schedule/event_duration_minutes/text()')"event_minutes"
    FROM fraamed_user.frmd_event_update , TABLE(xmlsequence(extract(xml_event_update, '/event_update')))b
    ...if yes, did you try nvl function (I don't think this would be a solution of a problem):
    SELECT version,frmd_transaction_date,nvl(extractValue(value(b), '/event_update/location/text()')"location", 'NULL VALUE'),
    nvl(extractValue(value(b), '/event_update/sending_system/text()')"sending_system",'NULL VALUE'),
    nvl(extractValue(value(b), '/event_update/event_identifier/text()')"event_identifier",'NULL VALUE'),
    nvl(extractValue(value(b), '/event_update/event_link/text()')"event_link",'NULL VALUE'),
    nvl(extractValue(value(b), '/event_update/organization_code/text()')"organization_code",'NULL VALUE'),
    nvl(extractValue(value(c), '/schedule/event_duration_minutes/text()')"event_minutes",'NULL VALUE')
    FROM fraamed_user.frmd_event_update , TABLE(xmlsequence(extract(xml_event_update, '/event_update')))b,
    TABLE(xmlsequence(extract(xml_event_update, '/event_update/schedule')))c
    If none of this works post your xml schema.

  • How to save only newly added elements from the trailing list

    Dear,
    I have a shuttle bean with left and right trailing lists.
    At some point I save the right trailing list content to DB. Then I add additinal elements to the trailing list. Trying to save again gives me oracle.jbo.TooManyObjectsException: JBO-25013: Too many objects match the primary key oracle.jbo.Key
    exception.
    What is the approach I can take to only save newly added elements from the shuttle?
    I am wondering if I can put the extra logic (what logic would that be - do I need to check the PK value that is already in the database?) in the AM method with which I save the shuttle like here (TicketID and ResponsibilityID are primary key)
    if (items != null)
    Object ia[] = items.toArray();
    for(int i=1; i<ia.length; i++)
    Row rowApproval = vo.createRow();
    vo.insertRow(rowApproval);
    rowApproval.setNewRowState(Row.STATUS_INITIALIZED);
    Row row = vo.getCurrentRow();
    row.setAttribute("TicketId",items.get(0));
    row.setAttribute("ResponsibilityId",items.get(i) );
    row.setAttribute("Status",items.get(i));
    or should I do something in the EO?
    Thank you
    Anatoliy

    Hi,
    Can you please clarify - do I have to make a loop? I mean for every record/element in the trailing list
    I run the VO (that I will create) VO.executeQuery?Yes you do need to execute the VO for every record....by passing the different parameter in each iteration.
    Regards,
    Gyan

  • [svn] 3140: Modifying build. xml to include templates in the jar from the new location.

    Revision: 3140
    Author: [email protected]
    Date: 2008-09-08 09:04:17 -0700 (Mon, 08 Sep 2008)
    Log Message:
    Modifying build.xml to include templates in the jar from the new location.
    Modified Paths:
    flex/sdk/trunk/modules/antTasks/build.xml

    Don't be so impatient and don't multipost! I've deleted your other thread about the same topic.

  • I have Photoshop Elements 12.  When I open the organizer, click on a picture, then want to use the Editor, I get an error message.  If I click on the Editor from the Welcome screen, error message.  What happened to my Editor?

    I have Photoshop Elements 12.  When I open the organizer, click on a picture, then want to use the Editor, I get an error message.  If I click on the Editor from the Welcome screen, error message.  What happened to my Editor?

    I would suggest un-installing via the Windows control panel and then download again and re-install. Try an alternative link and validate with your 24 digit serial number - click here for PSE downloads

  • Anyone bought Photoshop Elements from the Apps Store just recently?

    Anyone bought Photoshop Elements from the Apps Store, either recently (April 2014) or in the last 12 months, say? The version on the Apps Store is just the editor and so doesn't incorporate an organiser.
    I'm just wondering if anyone happens to know whether the Store edition of this app includes support for Canon RAW files of the CR2 type. I've looked all over the Adobe website for the answer but without success.

    Hi..
    You can post a question in the Adobe Photoshop Elements forum here.

Maybe you are looking for

  • ArrayList and double[]

    private double[] findAverageFace(ResultSet rs, int rows){         String path;         Scanner scanner;         int picn = 0;         double[] avgFace = new double[rows * rows];         try{             //System.out.println("scanning the result set")

  • Authenticating to Socks proxy using different accounts in a given JVM

    I have a J2EE application that runs some background jobs. Each of these background jobs need to connect to an external FTP server. However, all connections must go through a central SOCKS proxy server. The SOCKS proxy server is set up to require auth

  • PSE 8 Crash

    I recently installed PSE 8 on a computer running Windows Vista. PSE 8 was an upgrade from PSE 6 which is still installed on the same computer. For reasons I can't quite figure out, PSE 8 Organizer automatically shuts down without any error message. A

  • Moving disabled user to another OU

    Hi, I am using Oracle Identity Manager 9.1.9.1 with AD connector 9.1.1. When a user is disabled in oim (when the Disable check box in OIM is checked), I would like the user to be automatically moved to an another OU for disabled users. I have created

  • Hi Community, I have big Problems to activate the Iphone, i´ve bought a few days before (second Hand).

    You can read on the activation screen, that this iphones is linked with apple id [email protected] . I have this id and even the Password but if i go to the cloud with this id, there is no Iphone listed i could delete. And if i try to enter this  id