How do i parse this, using JDOM?!

This xml is in the form of a String, can someone tell me how to use JDOM to parse this, i've actually made a start:
SAXBuilder builder = new SAXBuilder();
Reader r = new StringReader(str1);
Document doc = builder.build(r);
<StockQuotes>
<Stock>
<Symbol>IBM</Symbol>
<Last>111.32</Last>
<Date>8/1/2007</Date>
<Change>+0.67</Change>
<Open>110.39</Open>
<High>111.95</High>
<Low>110.06</Low>
</Stock>
</StockQuotes>
and then im kinda lost... please help! really need it!
cheers,
Shivek Sachdev

hey,
thanks a lot for the reply.
i get the idea now, to be able to trace to the childrens
but it would be really helpful if u can give me a more complete version of the code, im really new to this stuff.
i did wat u told:
List stock = root.getChildren();
//now im at the 2nd level
how do i get to <Symbol> so that i can print out the value of that tag.
cheers,
Shivek Sachdev

Similar Messages

  • I have about 10000 images of different persons with dimension of 640*480. I wan to crop face from these images to dimension of 200*280. The location of face varies in differnt pics. So, please let me know step by step how can I perform this using the Ligh

    I have about 10000 images of different persons with dimension of 640*480. I wan to crop face from these images to dimension of 200*280. The location of face varies in differnt pics. So, please let me know step by step how can I perform this using the Lightroom software. Also I wan to know what should be the aspect ratio to do so.Thank you in advance

    The aspect ratio should be set to 200x280, or equivalently 5x7.
    I don't think it is possible to do the cropping automatically in Lightroom, you'd have to do this image by image to crop the faces correctly.

  • I have a 1.5 hour video of a concert from which I need to extract several 'tracks' as individual files, and then join them together in a new video. How do I do this using imovie?

    I have a 1.5 hour video of a concert from which I need to extract several 'tracks' as individual files, and then join them together in a new video. How do I do this using imovie?

    Adobe has made this process much simpler in recent years.
    No need to re-install any version earlier than the current version (CS6). All installers (upgrade or full) contain the full program code. The difference between full and upgrade is in the serial number.
    All you need do is download (link below) and install CS6, enter the CS6 upgrade serial number then enter the CS5 serial number (even if that too is an upgrade).
    Download CS6 products

  • Hi, I've been stolen and I need to find my iPhone, how can I do this using the IMEI?

    Hi, I've been stolen and I need to find my iPhone, how can I do this using the IMEI?

    You cannot do this using IMEI.
    If your iPhone, iPad, or iPod touch is lost or stolen - Apple Support
    Report a lost or stolen Apple product - Apple Support

  • Hot to parse XML using JDOM?

    <Case caseID="1808977179">
    <attr name="create_time">2003-12-04 16:42:19.0</attr>
    <attr name="name">1KEEJCE</attr>
    <attr name="owner_id">2yawpgx5vhpus</attr>
    <attr name="expected_closure">2003-12-04 16:42:19.0</attr>
    <attr name="subject">test tech support case</attr>
    </Case>
    obviously my attribute name (which is also named as "name") is the same for all my five entries. How can I parse all of them?I can only parse the first entry.

    this is the comp xml file:
    <GetUserCasesResponse>
         <Case caseID="1808977179">
         <attr name="name">1KEEJCE</attr>
         <attr name="create_time">2003-12-04 16:42:19.0</attr>     
         <attr name="owner_id">2yawpgx5vhpus</attr>
         <attr name="expected_closure">2003-12-04 16:42:19.0</attr>
         <attr name="subject">test tech support case</attr>
         </Case>
         <Case caseID="1326717944">
         <attr name="name">2DC65T5</attr>
         <attr name="create_time">2003-12-04 16:46:02.0</attr>
         <attr name="owner_id">2yawpgx5vhpus</attr>
         <attr name="expected_closure"></attr>
         <attr name="subject">test tech support case</attr>
         </Case>
         <Case caseID="1489179651"><attr name="name">16ZUFEZ</attr>
         <attr name="create_time">2003-12-04 16:48:15.0</attr>
         <attr name="owner_id"></attr>
         <attr name="expected_closure">2003-12-04 16:48:15.0</attr>
         <attr name="subject">test tech support case</attr>
         </Case>
         <Case caseID="1145690438"><attr name="name">2Y3XDR7</attr>
         <attr name="create_time">2003-12-04 16:56:17.0</attr>
         <attr name="owner_id">2yawpgx5vhpus</attr>
         <attr name="expected_closure">2003-12-04 16:56:17.0</attr>
         <attr name="subject">testing</attr>
         </Case>
         <Case caseID="1145690438"><attr name="name">2Y3XDR7</attr>
         <attr name="create_time">2003-12-04 16:56:17.0</attr>
         <attr name="owner_id">2yawpgx5vhpus</attr>
         <attr name="expected_closure">2003-12-04 16:56:17.0</attr>
         <attr name="subject">testing</attr>
         </Case>
    </GetUserCasesResponse>
    this is my code:
         public static void readXML( )
              try
                   SAXBuilder builder = new SAXBuilder( false );
                   Document doc = builder.build( new File(filenameConstant ) );
                   Element root = doc.getRootElement();
                   List listCase = root.getChildren("Case");
                   Iterator iterateCase = listCase.iterator();
                   while(iterateCase.hasNext())
                        Element attr = (Element) iterateCase.next();
                        System.out.println("" + attr.getChild("attr").getText() );
              catch( Exception e)
                   e.printStackTrace();
    This is my output:
    1KEEJCE
    2DC65T5
    16ZUFEZ
    2Y3XDR7
    2Y3XDR7
    Press any key to continue...
    Obviously I can only get the first element (<attr name="name">1KEEJCE</attr>
    ) of each cases,how can I get the other four given that they have the same attribute name ( which is named "name" ).

  • How do I create this using jQuery...Or even standalone javascript?

    Hi, what I'm trying to create has already been done but my lack of know how is holding me back from duplicating the effect as seen at  http://www.yidio.com/show/sons-of-anarchy
    Clicking the "Season" link/s expands the entirety of the master container element (<div> I believe) to reveal a long list of episodes. And then clicking the season link again hides it all.
    How do I do this? I appreciate any help as I have been struggling over this for a long time now...Thanks!  

    If an accessible solution is required,  Accordion Panel Magic does it all. But it is not free:
    http://www.projectseven.com/products/tools/accordion2/examples-options/cat01.htm
    Al Sparber - PVII
    http://www.projectseven.com
    Dreamweaver Menus | Galleries | Widgets
    http://www.projectseven.com/go/hgm
    The Ultimate Web 2.0 Carousel

  • Parsing Xml using Jdom

    Hi all,
    I am reposting it as I was told to format the code and send it again.
    I am trying to parse a xml file using a jdom java code.This code works fine if I remove xmlns attribute in the root element. (I get the expected result) .If the "xmlns" attribute is put in the xml as it should be then the parsing and retrieving returns null. Please tell me how to fix this issue.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Xml
    <process name="CreateKBEntryService" targetNamespace="http://serena.com/CreateKBEntryService" suppressJoinFailure="yes" xmlns:tns="http://serena.com/CreateKBEntryService" xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/" xmlns:bpelx="http://schemas.oracle.com/bpel/extension" xmlns:ora="http://schemas.oracle.com/xpath/extension" xmlns:nsxml0="http://localhost:8080/axis/services/CreateKBEntryService" xmlns:nsxml1="http://DefaultNamespace" xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/">
    <partnerLinks>
    <partnerLink name="client" partnerLinkType="tns:CreateKBEntryService" myRole="CreateKBEntryServiceProvider"/>
    <partnerLink name="CreateKBEntryPartnerLink" partnerLinkType="nsxml0:CreateKBEntryLink" partnerRole="CreateKBEntryProvider"/>
    </partnerLinks>
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
    Java:
    import java.io.*;
    import java.util.*;
    import org.jdom.Document;
    import org.jdom.Element;
    import org.jdom.input.SAXBuilder;
    public class sample1 {
    public static void main(String[] args) throws Exception {
    // create a XML parser and read the XML file
    SAXBuilder oBuilder = new SAXBuilder();
    Document oDoc = oBuilder.build(new File("**xml file location**"));
    Element root = oDoc.getRootElement();
    System.out.println(root.getName());
    String tgtns= root.getAttributeValue("targetNamespace");
    System.out.println("tgt ns "+ tgtns);
    List list= root.getChildren("partnerLinks");
    Iterator it1= list.iterator();
    System.out.println("Iterator 1 - "+list.size());
    while(it1.hasNext()){
    Element partnerlinks = (Element)it1.next();
    List list2= partnerlinks.getChildren("partnerLink");
    System.out.println("iterator 2 - "+list2.size());
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Result:
    Without Xmlns in xml file(Expected and correct output)
    process
    tgt ns http://serena.com/CreateKBEntryService
    Iterator 1 - 1//expected and correct result that comes when I remove xmlns attribute from xml
    iterator 2 - 2
    Result with xmlns:
    process
    tgt ns http://serena.com/CreateKBEntryService
    Iterator 1 - 0 //instead of 0 should return 1

    Hi all,
    I am reposting it as I was told to format the code and send it again.
    I am trying to parse a xml file using a jdom java code.This code works fine if I remove xmlns attribute in the root element. (I get the expected result) .If the "xmlns" attribute is put in the xml as it should be then the parsing and retrieving returns null. Please tell me how to fix this issue.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Xml
    <process name="CreateKBEntryService" targetNamespace="http://serena.com/CreateKBEntryService" suppressJoinFailure="yes" xmlns:tns="http://serena.com/CreateKBEntryService" xmlns="http://schemas.xmlsoap.org/ws/2003/03/business-process/" xmlns:bpelx="http://schemas.oracle.com/bpel/extension" xmlns:ora="http://schemas.oracle.com/xpath/extension" xmlns:nsxml0="http://localhost:8080/axis/services/CreateKBEntryService" xmlns:nsxml1="http://DefaultNamespace" xmlns:bpws="http://schemas.xmlsoap.org/ws/2003/03/business-process/">
    <partnerLinks>
    <partnerLink name="client" partnerLinkType="tns:CreateKBEntryService" myRole="CreateKBEntryServiceProvider"/>
    <partnerLink name="CreateKBEntryPartnerLink" partnerLinkType="nsxml0:CreateKBEntryLink" partnerRole="CreateKBEntryProvider"/>
    </partnerLinks>
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`
    Java:
    import java.io.*;
    import java.util.*;
    import org.jdom.Document;
    import org.jdom.Element;
    import org.jdom.input.SAXBuilder;
    public class sample1 {
    public static void main(String[] args) throws Exception {
    // create a XML parser and read the XML file
    SAXBuilder oBuilder = new SAXBuilder();
    Document oDoc = oBuilder.build(new File("**xml file location**"));
    Element root = oDoc.getRootElement();
    System.out.println(root.getName());
    String tgtns= root.getAttributeValue("targetNamespace");
    System.out.println("tgt ns "+ tgtns);
    List list= root.getChildren("partnerLinks");
    Iterator it1= list.iterator();
    System.out.println("Iterator 1 - "+list.size());
    while(it1.hasNext()){
    Element partnerlinks = (Element)it1.next();
    List list2= partnerlinks.getChildren("partnerLink");
    System.out.println("iterator 2 - "+list2.size());
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Result:
    Without Xmlns in xml file(Expected and correct output)
    process
    tgt ns http://serena.com/CreateKBEntryService
    Iterator 1 - 1//expected and correct result that comes when I remove xmlns attribute from xml
    iterator 2 - 2
    Result with xmlns:
    process
    tgt ns http://serena.com/CreateKBEntryService
    Iterator 1 - 0 //instead of 0 should return 1

  • How can I parse this date format?

    Hey,
    i am trying to write an interface between two applications. One application gives me the following date:
         Wed Jul 16 12:18:20 CEST 2003
    but I need it to look like this:
         16.07.03 12.18:20
    I tryed to use Date and DateFormat to parse and change it but the Date was unparseable.
    I hope somebody can point me to the right direction or show me how I can do the formating.
    Thanx a lot!
    Martin

    If this isn't a well-known date format, I can't see any solution but to write small function yourself which doe the job.
    you can start with :
    String source = "Wed Jul 16 12:18:20 CEST 2003";
    String[] elements = source.split();//splits source around spaces
    then you write functions that map day of week with numbers
    "Mon" --> 1
    "Tue" --> 2
    etc...
    it won't take you days to write this.
    Sometimes it's faster to write the stuff yourself than spending days looking for something pre-defined that may or may not exist.

  • I'd like to alter my Airport Extreme/Airport Express wireless network so that the 3 Expresses connect to the Extreme via Ethernet. I've been told this will create a more stable wifi signal. How do I configure this using Airport Utility? Thanks.

    I currently have an Airport Extreme Base Station connected to my DSL router by Ethernet. Because I have a long, sprawling home, I have 3 Airport Expresses configured to "Extend the Wireless Network" I've established. Because of my home environment--thick walls encompassaing wire mesh, sprawling rooms, etc., it is hard to maintain a continuously-strong, stable WiFi signal. I've been told that I can create a much more stable network by connecting the Express units to the AEBS via Ethernet cable. Since my home is already wired for Ethernet, I'm considering making this change. If I proceed to establish the Ethernet connections, how do I then set up Airport Utility to accomodate this switch from a Wireless-based WiFi network to an Ethernet-based WiFi network?
    Thanks in advance for any help.
    Phyllis

    I don't see anyplace in the Utility to designate HOW the Express units are connected, only how they relate on the network to the Extreme,
    As I mentioned in the previous post, when you click the Internet icon in AirPort Utility:
    Connect Using = Ethernet  (This tells each Express to connect to the Extreme using the ethernet connection)
    Connection Sharing = Off (Bridge Mode)  (This setting allows your AirPort Extreme to function as the "main" router on the network, as it must for the setup to work correctly.
    You do not need to configure anything differently on the AirPort Extreme (as long as it is working correctly now) to connect the AirPort Express devices.
    The only other question I have is the following: I'm currently already using one of the Ethernet ports on the back of the Extreme-- for my husband's iMac. I really don't think he gains much in performance over how the iMac would run through wifi, so I could disconnect the iMac. If you think the iMac would do better to stay on the Ethernet connection, should I use a switch/splitter to add an extra connection?
    Since each AirPort Express must connect using ethernet, you will need to use the 3 LAN <-> ports on the AirPort Extreme for the AirPort Express devices.
    I would suggest that you try connecting the iMac using wireless to see if that will work. If the wireless connection is not satisfactory, then you can add a 5 port ethernet switch to one of the LAN ports on the Extreme and then plug all the devices connecting using ethernet....the iMac and the 3 AirPort Express devices...into the remaining 4 ports on the switch. That will leave you with 2 open ports on the AirPort Extreme for any future devices that may need to connect.
    When you test out the system, here is a trick to find out which device your computer is actually connecting to at any given time as it "roams" around the house.
    When you have AirPort Utility open to configure each AirPort Express, jot down the AirPort ID for each Express. You can do the same for the AirPort Extreme.
    As you move around with your laptop, hold down the option key on your Mac keyboard while you click on the fan shaped AirPort icon at the top of the screen. Look for the BSSID. That is the AirPort ID of the device that the laptop is connected to at that time. it should also be the ID of the closest AirPort Express (or AirPort Extreme if the laptop is close to the Extreme at the time).
    Let us know how things are working when everything is up and running.

  • Need to send an email to 3,000 receipients how do i do this using mail?

    I am a small business and we have about 3,000 email contacts on our books. Occasionally we like to send them an email to show offers etc. Can anyone let me know the best way i could do this? at the moment my broadband supplier only allows me to send 20 emails at a time so i takes me forever to get through 3,000! On my old PC i used to be able to do an email mail merge via excel straight to outlook so after a few clicks it would automatically send to every customers individually so i could just leave it for 30 mins or so and it would be complete!
    Is there anyway i can do the same using mail? i am happy to use either excel or numbers to obtains this!
    Thanks in advance
    Andy

    Hi Andy
    Not really possible with Mail, but one program I've used and recommended is "Direct Mail". It integrates with your Address Book groups, and you can set a limit to how many emails it sends at a time.
    http://ethreesoftware.com/directmail
    Matt

  • How can I do this using Wildcards?

    Hi everyone,
    I have a classed called LabeledDecimal which is a subclass of BigDecimal. Now, I have a class called Pair which is written using Wildcards.
    This class has a copyFrom() method which looks like :
    public void copyFrom(T p2)
         this.first = p2.first;
         this.second = p2.second;
    }If I try to use this method like below:
    Pair<BigDecimal> p1 = new Pair<BigDecimal>();
    Pair<LabeledDecimal> p2 = new Pair<LabeledDecimal>(ld1, ld2);
    p1.copyFrom(p2);Then I get the error:
    The method copyFrom(Pair<BigDecimal>) in the type Pair<BigDecimal> is not applicable for the arguments (Pair<LabeledDecimal>)
    How do I fix the copyFrom() method to get rid of this problem using wildcards?
    Edited by: fantastic_ray on Mar 20, 2008 12:07 AM

    Figured it out!
    public void copyFrom(Pair<? extends T> p2) That will fix it.

  • How do I parse this string?

    I have a string of html , which looks like this:
    <head></head><body><p>Stringof<strong><em>tags</em></strong>inhtml</p>
    I have to go ahead a search for the tags and put them into a tree.
    for instance.
    <head> would be the root, then I would go to <p> and get the contents thereof, where <em> and <strong> would be child nodes.
    I am not sure how to look throw a string and search for these things. can anyone suggest a good way of doing this?
    Originally I was thinking of going through it like an array, but apparently that is illegal.
    Thanks.

    You're throwing away the first line of the file.
    This line of code:
                   String line = in.readLine();reads in the first line, but then you ignore what's in line.
    You should change it to just:
                   String line;Similarly, you're throwing away alternate lines of input with this line of code:
                        line = in.readLine();You should just remove that.
    [add] ...you're too fast for me
    Edited by: paulcw on Oct 18, 2008 5:44 PM

  • Anyone know how I can parse this string?

    Hello everyone!
    I'm using the Scanner class (which is like the StringTokenizer class but suppose to be more powerful).
    Anyways, I have the following String:
    OP '1.3.12.2.1004.212'.'1.3.12.2.1004.195'
    I want to parse the String so I have the following:
    '1.3.12.2.1004.212'
    '1.3.12.2.1004.195'
    so basically just parse it by the middle dot, I tried useDelimeter function and it doesn't parse it up at all. You would think it would have parsed every occurance of . but that isn't the case.
    Here is my code:
    else if(line.contains("OP"))
                             System.out.println("HIT THE SUBFIELD PART lulz");
                             String subClassName = "";
                             String subFieldName = "";
                             scan = new Scanner(line);
                             scan.useDelimiter(".");
                             System.out.println("LINE: " + line);
                             while(scan.hasNext())
                                  System.out.println("Token: " + scan.next());
                             }The output is the following:
    HIT THE SUBFIELD PART LOL
    LINE: OP '1.3.12.2.1004.212'.'iPAddress'
    Token:
    Token:
    Token:
    Token:
    Token:
    Token:
    Token:
    Any ideas what I can do to parse it up the way I mentioned above? thanks!

    hm..it just occured to me I could do the following
    else if(line.contains("OP"))
                             System.out.println("HIT THE SUBFIELD PART lulz");
                             String subClassName = "";
                             String subFieldName = "";
                             scan = new Scanner(line);
                             scan.skip("OP");
                             scan.useDelimiter("'.'");
                             System.out.println("LINE: " + line);
                             while(scan.hasNext())
                                  System.out.println("LOOK HERE: " + scan.next());
                             }I get the following output:
    LINE: OP '1.3.12.2.1004.212'.'iPAddress'
    LOOK HERE: '1.3.12.2.1004.212
    LOOK HERE: iPAddress'
    So I guess I can just manually manipulate that last token and readd the ' character!
    I think thats what I will do but if you can find a bettter solution let me know! thanks! :D

  • Need to create a searchable employee directory in Muse.  How can I do this using Business Catalyst?

    I have been tasked with updating our firm website, and have no prior web design experience.  Muse seems like a great option, but I understand that Muse has no database capabilities.  I was advised that I could find a way to incorporate a searchable employee directory (database) via Business Catalyst. Are there any links that show how to do this?

    Thanks, Adam.  I think this looks like a good option for us.  Here is our current, existing website, which I am tasked with updating:
    www.bstz.com
    Would you mind taking a look at the attorney directory, and confirming that the BC Meet the Team will allow me to create essentially the same sort of directory, with search fields, photos and cv?  I'm sure it will, but I just need confirmation before I go too much further down the design path.
    Right now I am just on trial Adobe Creative Cloud membership, so I was able to download and experiment with Muse.  I believe the cost to continue this would be about $15/month.  If I join Business Catalyst with eCommerce membership, would that be in addition to the Adobe Creative Cloud membership?  I'm going to need to give a proposal to my partners, and I want to make sure I am accurately stating the monthly costs.  We currently have our own in-house server, and I want to be able to rationalize moving away from that.
    Thank you for your continuing expertise.
    Ingrid
    BSTZ
    310.500.4750

  • How can I make this using coldfusion?

    Hi, I'd like to make a photo changing gallery as you see on
    the news sites when you click next it loads a new photo and text
    without reloading the page (
    http://news.aol.com/story/ar/_a/miners-families-outraged-in-utah/20070806121809990001)
    is this done in ajax? do you know where I can find the code
    or application to do this in coldfusion?
    Thanks

    this can be done with a simple image swaping javascript like
    the attached code, and then you call it with and onclick event
    like:
    "imageSwap('BigImage', 'myPicture.jpg');" to cycle through
    several images you can use a javascript array to hold all your
    image names and have the next button just increment through the
    list everytime you click it.

Maybe you are looking for

  • Google search wont open from drop down menu

    When I go to Google to search I open the drop down bar to select a previous search and it wont open I have to manually type in the search window to search.

  • How do i verify if Apple charging cable is original product of Apple?

    How do i verify if Apple charging cable is original product of Apple? The cable use to have id code on the cable but now no such id cable can be found on the cable which will be question upon by APPLE Staff should the cable is spoilt within the one y

  • RFC_NO_AUTHORITY dumps

    Hi Techies, We are facing one  issue with the RFC_NO_AUTHORITY dumps . We checked and found that as per the dump there is authorization missing for some function groups in the object S_RFC. User type is "System" and the client is 000. SInce 000 doesn

  • Setup Java system directory server 6 client for user authentication

    I am trying to set up a native LDAP client for sun directory server 6 for network based user authentication. I checked the sun doc for naming service (LDAP) and the documentation are for setting up LDAP client for directory server 5. Is there any doc

  • Procedure optimization

    Hi, I made a oracle procedure which takes 30 mins to get executed, i tried a lot but could optimize it further. Each table used has avg data of 40,000 records, the code which i have written is CREATE OR REPLACE PROCEDURE ESPF_ABPP.Testingperform AS r