How to get the second element in XML Response with same name

Hi All,
I am struck at this point, I have written a sample HTTP client which sends a request to the HTTP Server. In response to the request made the HTTP Server gives response in the XML format. eg: -
<?xml version="1.0"?>
<parent>
<node1> Value1 </node1>
<node1> Value2 </node1>
<node2> Value3 </node2>
</parent>
In the HTTP Client I am getting the value of node1 using the following statement: -
if (node instanceof Element && "node1".equals(((Element)node).getName()) )
String node1 = node.getStringValue();
System.out.println("Product Code:"+node1);
This is always returning the first node1 value i.e. <node1> Value1 </node1>.
The requirement is, I also need to get the <node1> Value2 </node1> value also. So can anyone tell me hw can I get the <node1> Value2 </node1> value. please tell me the piece of code that I should add to get the <node1> Value2 </node1>.
My Mode is something like this: -
try
               Document document = (Document)DocumentHelper.parseText(response);
               List<Node> transactionNodeList = document.selectNodes( "//parent" );
               for(Node singleNode:transactionNodeList)
                    for(int i=0,j=0;i< ((Element)singleNode).nodeCount();i++ )
                         Node node = ((Element)singleNode).node(i);
                         if (node instanceof Element && "node1".equals(((Element)node).getName()) )
node1= node.getStringValue();
System.out.println("Air Way Bill Number:"+node1);
if (node instanceof Element && "node1".equals(((Element)node).getName()) )
node1= node.getStringValue();
System.out.println("Product Code:"+node1);
Thanks in Advance

DocumentBuilderFactory factory=DocumentBuilderFactory.newInstance();
     DocumentBuilder db=factory.newDocumentBuilder();
     Document doc=db.parse(new File(ur xml file"));
     Element root=doc.getDocumentElement();
     System.out.println("root "+root.getNodeName());

Similar Messages

  • Help!!! How to get the recovery time of transient response of a power supply with Labview basic package without analysis option?

    How to get the recovery time of transient response of a power supply with Labview basic package without analysis option? Does anyone have any idea or some similar function SUBVIs?
    Recovery time of transient response is defined as the time from the beginning of the transient to the voltage point on the waveform fallen into 10percent of the overshoot. Well, the waveform is something like a pulse with a soft slope.

    I recommend plotting your data on a graph on paper. Take a look at the data, and determine what is unique about the point you are looking for. Look for how you can teach your program to look for this point.
    I have written several algorithms that do similar, one in fact being for a power supply, the other being for RPM. Neither algorithm used any advanced analysis tools. They are just a matter of determining, mathematically, when you achieve what you are looking for. Just sit down with your graph (I recommend multiple copies) and draw horizontal and vertical lines that determine when you get to the point you are looking for. You are probably going to have to reverse the array and start from the end, so think in those terms.
    If you have trouble, emai
    l me a bitmap of the graph, and what you are looking for and I will try to be of further assistance. Don't do that however; until you you have given this a few tries. Your solution should be involve a lot of logic on analog levels.
    Good luck

  • How to get the last element of a structure in a textfield in DesignStudio

    Hello,
    how can I get the last element of a structure within a bex query?
    Within the structure we are working with dates that dynamically are buiId (input date - offsets for several months).
    I have to show the last value in a single textfield within DesignStudio.
    Regards
    Frank

    Hi Frank,
    in DS 1.3 you can use forEach function to get the last element of BEx structure (or n-th element in general using if condition)
    var array = DS_CROSSTAB1.getMembers("DHGY5D6XEFO1K45SB00BXFH7A",10);
    var lastMember="";
    array.forEach(function(element, index) {
           lastMember = element.text;
    TEXT_1.setText("Last structure element: "+lastMember);

  • How to get the encoding of a XML file ...

    Hi,
    How do you get the encoding of a XML file?
    For example,
    <?xml version="1.0" encoding="SJIS"?>
    I am trying to retrieve the above encoding="SJIS", but I can't seem to locate the API for doing so.
    Thanks in advance for any help,
    Eric

    Hi ddossot,
    Thanks for your suggestion.
    However, the xerces.jar file that comes with my old tomcat server is an old version and thus, the getEncoding method is not even present in the DocumentImpl class. The option to update to a newer version of tomcat and xerces is not available. What a pity... :-(
    Well, I just have to try to find a way around. Worst case scenario, parse the first line in the xml file myself.
    Regards,
    Eric

  • How to get the context element of a F4 help of a column in ALV table?

    Hello!
    I know to get the context element of the current row normally through
    lo_el = WDEVENT->get_context_element( 'CONTEXT_ELEMENT' ).
    or: lo_el = lo_nd->get_element( index = r-parm->index ).
    But this time, I have a F4 help on the cell of a column. After clicking on the F4 help I need to get the current context element. Do you have any idea, to help me?
    Many thanks!
    regards
    Meer

    Hello,
    Kindly close the thread if your query is resolved now.
    Thanks
    Pradeep

  • How to get the original look of firefox 4 with 'firefox button' on top then bookmarks lane following with address bar..?

    i have been using firefox 3.6.16 and just upgraded to version 4 last night. actually the problem is this, in my browser the 'firefox button' and all tabes are shown in the same lane on top.
    what i want is to get the default look of firefox 4 with firefox button on top and all the tabs appearing on beneath this button..(not in same lane)
    am i having due to any preference setting or else? please help

    If the Firefox window is maximized, it will display the tabs in the same line as the Firefox button, it only displays them on a separate line on a non-maximized window.

  • How to get the "encoding" of a XML file using JDOM

    As in XML file, <?xml version="1.0" encoding="UTF-8" ?> indicates the encoding of this file
    while using JDOM to parse a XML file, how can I get the encoding type?
    thanx!!!

    What my program do is to get the encoding of XML files and convert them to UTF-8 encoding files, while I need this "encoding" information of the original XML document thus I can convert...
    After reading specifications and JDOM docs, the truth turns to be disappointed, no function is provided to get this information in JDOM level 2(the current released one), while it's promissed that this function will be provided in JDOM level API....
    Thanx all for your help and attention!!!

  • How to get the  page count in XML Publisher Report

    Hi Team,
    I am generating one xml report. I want to get the total Page count in XML publisher report. This page count is depends on the input Parameters at runtime. How to get this total page count on the runtime dynamically.
    Best Regards
    Sri

    there is some seeded variable available please read xml publisher developer user guide

  • How to get the text elements for a particular program

    Hi All,
    I want to get the all text elements , selection texts for a particular program...How to get.
    I have used one FM READ_TEXTELEMENT_FROM_REPORT , but not much useful..
    please help me..
    Regards,
    raj

    Hi..
    You may use this statement to read the text elements:
    DATA: i_reptx  TYPE STANDARD TABLE OF textpool   WITH HEADER LINE.
    READ TEXTPOOL (reports) INTO i_reptx. " reports is the report name.
    Best Regards,
    Pradeep.

  • How to get the customized page's xml version ?

    Hi All,
    I have created some fields (of style 'MessageChoice', 'MessageLovInput') through personalization in a page and after that i navigated to the middle-tier where our MDS repository holding all the page's source file (in form of XXXXPG.xml) to get the updated version of the same page in xml version.
    But i couldn't get the latest version of page's XML file instead i found the old standard file only.
    Please help me in getting the file and guide me the path if it got stored somewhere in the architecture.
    Thank You,
    Thiyagarajan

    Dear Anoop,
    Thanks for your immediate response.
    Could you please pour your ideas how to store the custom personalizations in Unix box through Functional Administrator responsibility ?
    And one more question is as you said it will be stored in the form of xml but i have searched the page in the middle tier where it(standard one) got stored, but unable to find any one. How to find the xml file after doing the personalizations and in which path ?
    Waiting for your reply.
    Thank You,
    Thiyagarajan

  • How to get the programs (elements and premiere)from my old computer on my new PC?

    Can I get the programs from my old computer and use tham on my new (windows 8.1) computer?
    what do I do?

    I just did this so I hope I can remember.  I have a MAC so I went into my MAC hard drive and then library > application support > adobe > photoshop elements > 10 > creations > effects.  I selected all of my files and copied them.  I then went back to photoshop elements > 12 > creations and pasted the files into effects.  I then restarted PSE and all of my files were there! 

  • How to get the list element label ? Please help

    Dear all
    I have a problem.
    I need to get the current list element lable
    for example
    the emp_list displays the employee_name and return the employee_id
    I need the following:
    when_list_change , i need to put the label of the selected element in a text item :EMP_NAME_TEXT
    I can put the put the element value easily when the user select an element
    :EMP_NAME_TEXT := :emp_list ;
    I need to put the label not the value
    please help

    Hi,
    Try out the get_list_element_label built-in function.....
    Find info in the on-line help.....
    Regards,
    Simon

  • How to get the first element of a List?

    Hi,
    I have the following hierachy:
    A (top level)
    -A1 (child of A)
    -B1 (child of A)
    --B11 (child of B1)
    --B12 (child of B1)
    I have an UDA on members B11 and B12 that have the same name as A1, and I use it to allocate values from A1 to B11 and B12. After that I want to aggregate the hierachy so I can have B1 and A with values.
    I would like to use the ancestors function to do that but Ancestors need a member as parameter and the only relation between A1 and B11 and B12 is the UDA.
    I can't do @ANCESTORS(@UDA(dimName, "A1")) because of that, so I would like to use a function to get at least 1 member that has the UDA I want and to use Ancestors on it, however I can't seem to find a function that returns the first member of a List.
    Can someone help me on this?
    Thank you

    Unfortunately it doesn't work. @List requires members names so I can't provide a member set as an argument :(^^^Are you sure? Take a look at the below example from the Tech Ref. That sure looks like @LANCESTORS and @LIST is accepting more than just member names.
    FIX(@LANCESTORS(@LIST(@ATTRIBUTE(Caffeinated_True),@ATTRIBUTE(Ounces_12),"200-40")))Also note this:
    If the @LANCESTORS function is used alone (not within a FIX statement), you must use the @LIST function and specify member names. So you DO have to use @LIST if @LANCESTORS is to be used to do an aggregation. Or so it appears.
    Regards,
    Cameron Lackpour

  • How to get the second and third.... words in a string

    Hi all,
    is there any way to get the words in a string seperate columns in a row.
    "xxx yyyy zzzz aaaa bbbb"
    required answer is
    a b c d e
    xxx yyyy zzzz aaaa bbbb
    a b c d e are the column names
    Thanks

    WITH t as (
      SELECT 'xxx yyyy zzzz aaaa bbbb' as t FROM dual
    -- end of sample data.
    SELECT t,
           regexp_substr(t, '[^ ]+', 1, 1) as a,
           regexp_substr(t, '[^ ]+', 1, 2) as b,
           regexp_substr(t, '[^ ]+', 1, 3) as c,
           regexp_substr(t, '[^ ]+', 1, 4) as d,
           regexp_substr(t, '[^ ]+', 1, 5) as e
      FROM t;
    T                       A                       B                       C                       D                       E                    
    xxx yyyy zzzz aaaa bbbb xxx                     yyyy                    zzzz                    aaaa                    bbbb                   

  • How to get the filename when parsing a file with d3l

    All
    After some time have experience with interconnect, IStudio I need the following info. Is it possible to get the filename when parsing a flat file using a d3l? This is needed because we need to store the filename together with the data into the database.
    Any examples or directions to some documents are welcome.
    Regards
    Olivier De Groef

    has anyone some info on this

Maybe you are looking for