How to get data using JDOM

Hi,
I have this xml file stored in operator.xml
<Operator>
     <Customer>
          <Name>sam</Name>
          <Street>albert str.</Street>
          <ZipCode>45454</ZipCode>
          <City>NY</City>
          <Country>USA</Country>
          <EMailAddress>[email protected]</EMailAddress>
          <MeterNumber>1000</MeterNumber>
          <MeasuringUnit>kWh</MeasuringUnit>
          <Reading>
          <Month>1</Month>
          <Value>900</Value>
          </Reading>
          <Reading>
          <Month>2</Month>
          <Value>725</Value>
          </Reading>
          <Reading>
          <Month>3</Month>
          <Value>950</Value>
          </Reading>
     </Customer>
</Operator>I have the following getter statements in my code:
String name=req.getName();
int month=req.getMonth();Now, I want to get value for particular customer (by checking name for equality with getter) and for particular month( by checking for equality with getter).
I have written the following statements:
final String filename="operator.xml";
SAXBuilder builder=new SAXBuilder(true);
Document doc=builder.build(filename);
Element root=doc.getRootElement();How to proceed further using JDOM. I am confused with getChild(), getChildText() etc.,
thanks,

Obtain values with the JDom XPath class selectSingleNode and selectNodes methods.
SAXBuilder saxBuilder=new SAXBuilder("org.apache.xerces.parsers.SAXParser");
org.jdom.Document jdomDocument=saxBuilder.build(new File("c:/input.xml"));
org.jdom.Element zipcodeNode= (org.jdom.Element)(XPath.selectSingleNode(jdomDocument,"/Operator//Customer/zipCode"));

Similar Messages

  • How to get data using BEx variable

    I've build a universe upon a Bex query with a variable.
    When refreshing a WeBi report upon this universe with the filter (BEx variable) it works fine and returns data. The same does the QaaWS.
    But when I use this QaaWS as a source for Xcelsius dashbord it doesn't return any data. The input value for the variable is the same in all cases, e.g.  K4/2009.
    What should be done to fix the issue?

    What Xcelsius patch version you use?
    If I recall correct, this is known issue that was suppose to be fixed in Xcelsius 2008 SP2
    [SP2 direct download URL|https://websmp230.sap-ag.de/sap/bc/bsp/spn/download_basket/download.htm?objid=012002523100009338662009D&userid=I055661&action=DL_DIRECT]
    Thanks
    Subhodeep

  • How to get data from a USB-UIRT device using Labview?

    How to get data from a USB-UIRT device using Labview?
    I'm trying to get data from a USB-UIRT device, is it posible with Labview?
    I really appreciate your help, 
    thanks

    You may want to contact the developer of the device for the API and DLL.
    http://65.36.202.170/phpBB2/viewforum.php?f=3

  • How to get data type of variable in program..

    Hi ABAP Guru.
    I need to know how to get data type of variable or any structure field.. because I got short dump when use command REPLACE ALL OCCURANCE ... with variable/structure field that has data type I or P, I think it should be used with data type CHAR only, So I need to check the data type first.
    Please give me your advice
    Thank you all.
    Nattapash C.

    data : v_value type i,
             v_char(10) type c.
    v_value = 10.
    move v_value to v_char.
    REPLACE ALL OCCURRENCES of '#' from v_char....
    Best regards,
    Prashant

  • How to Select data using same column name from 3 remote database

    Hi,
    Can anyone help me on how to get data with same column names from 3 remote database and a single alias.
    Ex.
    SELECT *
    a.name, b.status, SUM(b.qty) qantity, MAX(b.date) date_as_of
    FROM
    *((table1@remotedatabase1, table1@remotedatabase2, table1@remotedatabase3)a,*
    *(table1@remotedatabase1, table1@remotedatabase2, table1@remotedatabase3)b)*
    WHERE b.dept = 'finance'
    AND a.position = 'admin'
    AND a.latest = 'Y' AND (b.status <> 'TRM') AND b.qty > 0;
    GROUP BY a.name, b.status ;
    NOTE: the bold statements is just an example of what I want to do but I always gets an error beacause of ambiguous columns.
    Thanks in advnce. :)
    Edited by: user12994685 on Jan 4, 2011 9:42 PM

    user12994685 wrote:
    Can anyone help me on how to get data with same column names from 3 remote database and a single alias.Invalid. This does not make sense and breaks all scope resolution rules. And whether this is in a single database, or uses tables across databases, is irrelevant.
    Each object must be uniquely identified. So you cannot do this:
    select * from (table1@remotedatabase1, table1@remotedatabase2, table1@remotedatabase3) a3 objects cannot share the same alias. Example:
    SQL> select * from (dual, dual) d;
    select * from (dual, dual) d
    ERROR at line 1:
    ORA-00907: missing right parenthesisYou need to combine the objects - using a join or union or similar. So it will need to be done as follows:
    SQL> select * from (select * from dual d1, dual d2) d;
    select * from (select * from dual d1, dual d2) d
    ERROR at line 1:
    ORA-00918: column ambiguously definedHowever, we need to have unique column names in a SQL projection - so the join of the tables need to project a unique set of columns. Thus:
    SQL> select * from (select d1.dummy as dummy1, d2.dummy as dummy2 from dual d1, dual d2) d;
    DUM DUM
    X   X
    SQL> I suggest that you look closely at what scope is and how it applies in the SQL language - and ignore whether the objects referenced are local or remote as it has no impact to fundamentals of scope resolution.

  • How to get data from MS CRM into Crystal Reports

    Hello All,
    Can anybody tell me how to get data into   crystal XI reports with MS CRM.
    Thanks in Advance
    Ramesh

    First you should refer to the Rules of Engagement and then add more info.
    Start off by telling us what version of CR are you using and what is MS CRM?
    Thank you
    Don

  • How to get data into BI system

    Hi Experts,
             I am a newbie to SAP BI. Please guide me how to get the data from tha R/3 tables into BI system tables. When I check the data in SE11 in R/3 (for ex: VBAK, VBAP...... etc), I could see all the records. Now how can I get the same data in BI system tables? When I check in BI system with Tcode SE11, I couldn't find any data for the tables VBAK,VBAP..... etc. Please guide me how to fill these tables in BI from R/3. Points will be rewarded for the solutions.
    Regards,
    Ravi

    Hi Ravi,
        U can follow the link and know how to get data from R/3 to BI.
    <a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/28/4c553c42360a40e10000000a114084/frameset.htm">data sources</a>
       Still I give overview to u. U need to create data source in R/3 side, replicate them in BI and use them in your info source to load the data. Data source are of two type application specific (system generated) and generic (customer defined). Data Extraction can be based on table, view or infoset query.
    hope this helps.
    Regards,
    Purvang
    Assigning Point is to say Thanks in SDN *

  • How to get data on the next page in case of templates if data is more ?

    please tell me how to get data on the next page while i m using template in my first page , if data is more howw it can be displayed on the next page ?

    HI Asim,
    template is fixed we  it can't be expand . u can better to use table line it can automaticlly expending if data is more ... u can create one more page like page 2 and create a window for entire second page ..then assign it in first page (next page page2).
    regards
    kiran kumar.

  • How i get data in matrix grid from A/P Invoice

    How i get data in matrix grid from A/P Invoice before click add button

    Hi,
    Are you trying to read the data in the matrix of a system form? Then you only have to look for the matrix with the ID you can see by visualising the System Information in B1 and then directly read from the matrix cells (using columns element in matrix), the DBDataSources are not filled in until the document has been added to the database.
    There are many messages in this forum talking about how to read information in matrix item, just make a search for it.
    Hope it helps
    Trinidad.

  • How Adobe gets DATE and its format?

    Hello,
    I am getting current (todays) date by using below JS in some flds, and by using below FormCalc for some flds into my_form,
    JS:
    var currentTime = new Date()
    Form Calc:
    $.rawValue = num2date(date(), DateFmt(MM/DD/YYYY))
    But, i dont have much idea that how adobe is getting this date? For my company this is the very first form, hence they are asking me how adobe gets date and its format whether,
    1) From local IP/Interner provider address's date, format?
    2) or user PC/laptop's LOCAL settings date, format? if so, for example, if Germany user (Laptop settings) has a DD.MM.YYYY configured, if this user comes to US on a busines trip and if that user opens the form, then how the date looks like for this user? as per user laptop settings DD.MM.YYYY or local internat provider date format MM//DD//YYYY?
    Thank you

    Hi,
    the date() function returns the number of days since 01.01.1900 for the local date of the current system (related to the system clock of the OS).
    If you travel from Germany to the US but don't update your date/time settings, then it returns the same date in the US as in Germany.
    You can check the behavior by changing your local date/time setting or the timezones.

  • How to get data out of XML?

    Hi,All.
    I am running SAX (JAXP1.01) in Applet to process XML file. My question is how to get data out of xml format according to the field name (@age,@rank etc)
    and write into string buffer seperated by comma.
    Should I use SAX or DOM? (file size is big)
    My xml as follow :
    <ROOT>
    <FormattedReportObject>
    <FormattedReportObject xsi:type="CTFormattedField" Type="xsd:string" FieldName="{@team/relay}">
         <ObjectName>Field124</ObjectName>
         <FormattedValue>HUNTER</FormattedValue>
         <Value>HUNTER</Value>
    </FormattedReportObject>
    <FormattedReportObject xsi:type="CTFormattedField" Type="xsd:string" FieldName="{@age}">
         <ObjectName>Field125</ObjectName>
         <FormattedValue> 19</FormattedValue>
         <Value> 19</Value>
    </FormattedReportObject>
    <FormattedReportObject xsi:type="CTFormattedField" Type="xsd:string" FieldName="{@Rank}">
         <ObjectName>Field126</ObjectName>
         <FormattedValue>43</FormattedValue>
         <Value>43</Value>
    </FormattedReportObject>
    <FormattedReportObject xsi:type="CTFormattedField" Type="xsd:string" FieldName="{results.athrel_name}">
         <ObjectName>Field127</ObjectName>
         <FormattedValue>1-1 NORRIE</FormattedValue>
         <Value>1-1 NORRIE</Value>
    </FormattedReportObject>
    <FormattedReportObject xsi:type="CTFormattedField" Type="xsd:string" FieldName="{@timefield2}">
         <ObjectName>Field128</ObjectName>
         <FormattedValue>1:54.75</FormattedValue>
         <Value>1:54.75</Value>
    </FormattedReportObject>
    <FormattedReportObject xsi:type="CTFormattedField" Type="xsd:string" FieldName="{@timefield1course}">
         <ObjectName>Field129</ObjectName>
         <FormattedValue/>
         <Value/>
    </FormattedReportObject>
    <FormattedReportObject xsi:type="CTFormattedField" Type="xsd:string" FieldName="{@timefield1std}">
         <ObjectName>Field130</ObjectName>
         <FormattedValue/>
         <Value/>
    </FormattedReportObject>
    <FormattedReportObject xsi:type="CTFormattedField" Type="xsd:string" FieldName="{@timefield2course}">
         <ObjectName>Field131</ObjectName>
         <FormattedValue/>
         <Value/>
    </FormattedReportObject>
    <FormattedReportObject xsi:type="CTFormattedField" Type="xsd:string" FieldName="{@timefield2std}">
         <ObjectName>Field132</ObjectName>
         <FormattedValue>QT</FormattedValue>
         <Value>QT</Value>
    </FormattedReportObject>
    <FormattedReportObject xsi:type="CTFormattedField" Type="xsd:string" FieldName="{@points(left)}">
         <ObjectName>Field133</ObjectName>
         <FormattedValue/>
         <Value/>
    </FormattedReportObject>
    <FormattedReportObject xsi:type="CTFormattedField" Type="xsd:string" FieldName="{@pointsdecimal}">
         <ObjectName>Field134</ObjectName>
         <FormattedValue/>
         <Value/>
    </FormattedReportObject>
    <FormattedReportObject xsi:type="CTFormattedField" Type="xsd:decimal" FieldName="{@points(right)}">
         <ObjectName>Field135</ObjectName>
         <FormattedValue>0</FormattedValue>
         <Value>0.00</Value>
    </FormattedReportObject>
    <FormattedReportObject xsi:type="CTFormattedField" Type="xsd:string" FieldName="{@timefield1}">
         <ObjectName>Field136</ObjectName>
         <FormattedValue>1:55.98</FormattedValue>
         <Value>1:55.98</Value>
    </FormattedReportObject>
    <FormattedReportObject xsi:type="CTFormattedField" Type="xsd:string" FieldName="{@Rank}">
         <ObjectName>Field137</ObjectName>
         <FormattedValue>43</FormattedValue>
         <Value>43</Value>
    </FormattedReportObject>
    Repeat...
    </FormattedReportObject>
    </ROOT>
    ------------------------------------------------

    For big files use SAX: quicker and less memory usage.
    The xerces parser from Apache has some examples. Basically what you do is scan the XML, remembering what tag you are and once you find the right tag, read the contents.

  • How to get  data with the raw pattern from resultset ?

    would you tell me how to get data with the raw pattern from resultset ?
    thank you in advance!
    longgger2000

    I tried getBytes() and getObject()
    , but I can not get the right result , for example the
    data in oracle database is 01000000DFFF, when In used
    the method of getBytes() and getObject(), I get the
    result of [B@1c2e8a4, very different , please tell me
    why !
    thank you
    longgger2000
    [B is byte arrayseem that it return an bytes array for you.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • How to get data to internal table from function module tr_inspect_objects

    How to get data from funtion module to an internal table .
    function module name is tr_inspect_objects(code inspectore  se10)
    how top collect all   task request data into one internal table using this fm or we have to create another fm .
    If you have already made FM please give us the code .

    Hi,
    You can use tables E070 or E071 to get data into your internal tables instead of a function module.
    Hope this helps.
    BR
    Dep

  • How to get data for custom feilds for standard datasource

    i have extracted CRM standard datasource 0CRM_OPPT_I.
    In RSA6 i slected feilds which i want to trnasfer to B Iand i also added some custom feilds.
    and then i went to RSA5 and i activated datasource.then i went to RSA3and  i extracted.
    In rSA3 selection screen all the custom feilds are selcted.
    after extraction if i go to LIST,only some of the custom feilds data is displaying remaining feilds displayed as blank data
    please tel me how to get data
    Thanks in advance
    HP

    Hi Hari,
    Sorry for late reply.
    Once you have done the proper mapping by using the transaction BWA1
    you need to write the BADI code which can be accesible from the following path:
    Go to transaction SPRO
    SAP Implementation guide ->Integration with other mySAP components ->Data transfer to the Business Information Warehouse->
    Settings for the application specific datasources (CRM) ->
    Settings for BW adapter->Execute Badi :BW adapter :Enhancement of datasources in messaging flow.
    Select you the datasource enhancement implementation it will open the BADI Implementation..
    go To interface tab and double click on the method..it takes you to the ABAP screen where you need to write the logic to populate the custom fields..
    Please feel free to mail back if you have any quries.
    All the Best..
    Thanks
    SK

  • How to get Date Format from Local Object.

    Hi All,
    I am new to Web Channel.
    I need to know Date format From date of locale.
    suppose there is a date "01/25/2010" date in date field I want to get string "mm/dd/yyyy". Actually I have to pass date format to backend when I call RFC. 
    Is there any way to get Date format from "Locale" object. I should get date format for local object
    I get local object from "UserSessionData" object but how to get Date format from it.
    I am not looking for Date value. I am looking for current local date format ("mm/dd/yyyy or dd/mm/yyyy or mon/dd/yyyy) whatever local date format.  I could not find example which show how to get date format from "Locale" object.
    Any help will be appreciated with rewards.
    Regards.
    Web Channel

    Hi,
    You can get it from "User" or "Shop" business object.
    Try to get User or Shop Business Object as shown below.
    BusinessObjectManager bom = (BusinessObjectManager) userSessionData.getBOM(BusinessObjectManager.ISACORE_BOM);
    User user = bom.getUser();
    char decimalNotation = user.getDecimalPointFormat().getGroupingSeparator();
    If you are seeing "1,234.00" then above code will return "."
    I hope this information help you to resolve your issue.
    eCommerce Developer.

Maybe you are looking for