How to retrieve a node using xpath in java

Hi,
I need to make an application in which on click of a button an xml is
displayed on the browser.
Now when a user selects a node in the xml then i need the xpath of the selected node for some processing.
How to retrieve the xpath.
I am using Struts framework.

There is not a specific method for achieving this.
You can store the whole xml document into a defined
structure. And get the needed xpath by some index.Yes i know that i'll need to store the file.
But my XML is fixed and the same XML is used everytime.
Now the structure of the XML is like it has same named nodes inside the parent node.
example :
<Human>
<Person>
<Person></Person>
<Person>
<Person><name>fsfsdsdf</name></Person>
</Person>
</Person>
<Human>
Now if the user selects the person node which contains name node then how to get the XPATH.
Can u help regarding the same........

Similar Messages

  • How to retrieve multiple columns using "returning" in the Insert query.

    hi,
    wanted to know how to retrieve multiple columns using "returning" in the Insert Query.
    For retrieving one column we write the query as follows:
    Insert into TABLE values(1,2,3,4) returning COLUMN1 into PARAMETER
    But can we retrive multiple columns in the same query?
    am using oracle 10g and coding in .NET

    Hi,
    You can definetely get multiple values from a single query using the 'returning' clause.
    Eg : insert into emp (empno, ename, job, deptno) values (7324,'ADAM','MARKETING',30) returning ename, deptno into var1, var2; PN : var1 & var2 to be declared as varchar2 & number respectively.
    More insight into the 'RETURNING' clause in this link.
    http://www.samoratech.com/PLSQL/swArtPLSQLReturn.htm
    Regards,
    Bhanu.

  • How to retrieve character '#' when use Shift key + 3 instead of use Option key + 3?

    Hi everyone,
    Kindly advice how to retrieve character '#' when use Shift key + 3 instead of Option key + 3.
    Thank you in advance.

    Hi Tom,
    Thanks for your proposed solution. The problem has been solved.

  • Retrieve xml attribute value of nth xml node using xpath query

    I have an xml with following stucture...
    <xml>
    <header>
     <DocumentReference OrderId="order001">
     <DocumentReference OrderId="order002">
     <DocumentReference OrderId="order003">
    I have to loop through this xml and retrieve the orderId values inside Biztalk orchestration.
    In the expression shape, I get the count of 'DocumentReference' nodes using an xpath query and then
    Added a loopshape to make sure it loops thru all nodes
    Loop condition:   n<=nodeCount     (where n is an integer variable, n=0 to begin with, incremented by 1 thru each loop, nodeCount is # of DocumentReference nodes)
     I try retrieve to the orderId in the following expression shape using the below xpath query
      xpathQuery = System.String.Format("//*[local-name()='OrderReference'][{0}]/@orderID)",n);
      sOrderId = xpath(MsgSingleInvoice,xpathQuery);
    And I get the following exception:
    Inner exception: '//*[local-name()='OrderReference'][1]/@orderID)' has an invalid token.
    Exception type: XPathException
    Appreciate any help!   thanks!

    Thanks for the quick response. I got rid of it.
    And I see a different error:
    Inner exception: Specified cast is not valid. Exception type: InvalidCastException
    Source: Microsoft.XLANGs.Engine  
    Target Site: System.Object XPathLoad(Microsoft.XLANGs.Core.Part, System.String, System.Type)
    Since variable 'n' is of integer type, I suspected it and changed it to n.ToString() and tested again and still see the same error.

  • How to retrieve the system used in an iview?

    hello,
    i'm currently having trouble retrieving the proper attribute of an iview to retrieve the system used by it.
    it seem like the strings identifying the system in the iview differ in some iviews.
    using either:
    myIView.getAttribute(IAttriView.PORTAL_SYSTEM)
    or
    myContext.getAttributes("").get("System").get().toString()
    produce errors.
    while get("System") sometimes provides the correct system alias the attribute is none existant for other iviews where the string would be "Systemalias".
    IAttriView.PORTAL_SYSTEM doesn't seem to work at all.
    i did implement fail safe code if the attribute isn't present, however i don't know how to retrieve the system attribute without doing a case switch or something similar for all the different strings, which i would prefer not to do.
    also, is there an easy way to retrieve all iviews which use a specific system without parsing the whole pcd and checking the attributes?

    Prerequisite : Create the System Alias for the systems used in the application.
    Use the below code to retrieve the system details:
            HashMap mapattr = new HashMap();
            HashMap map = new HashMap();
            IUser user = WDClientUser.getCurrentUser().getSAPUser();
            IPrincipal principal = (IPrincipal)user;
            ArrayList list = UMFactory.getSystemLandscapeWrappers();
            ISystemLandscapeWrapper systemLandscape = (ISystemLandscapeWrapper)list.get(0);
            //Portal System ALias name
            ISystemLandscapeObject landScapeObject = systemLandscape.getSystemByAlias("<system alias name>");
            IUserMappingData userMapping = (IUserMappingData) UMFactory.getUserMapping().getUserMappingData(landScapeObject,principal);
            userMapping.enrich(map);
            mappedUserId = map.get("user").toString(); // String "UserId"
            mappedPassword = map.get("mappedpassword").toString(); //String "Password" 
         catch(Exception e)
              e.printStackTrace();
              wdComponentAPI.getMessageManager().reportException("Exception during retrieving the User Details - " + e.getMessage(),true);
    Thanks & Regards,
    Amar Bhagat Challa

  • How to access a node using ID?

    Hi All,
    I have defined specific id for each node object. How can i access one particular node using the id?
    Can any one help me on this?
    Thanks,
    Thamizharasu S

    Hello!
    I just started to create my first javafx apps and stumbled upon the same problem. How can I access a Node which is identfied by the ID attribute?
    Text {
      id:"txt_greeting"
      content: "Click me to greet!"
      onMouseClicked: function( e:MouseEvent ):Void {
         //Access myselft to change the content attribute
    ...Any ideas?
    Thanks in advance.

  • How to retrieve export parameters using startrfc?

    When using the standard SAP client program <b>startrfc</b> to  remotely call an ABAP function in SAP, is it possible to retrieve the export parameters?
    The startrfc program only seems to allow you to send an import parameter (using the –E option)  and to send/retrieve a table, using the –T option.
    For example, the function BAPI_USER_EXISTENCE_CHECK exports the parameter RETURN of type BAPIRET2. How can you retrieve this export parameter using the startrfc program?

    HI Linda,
    Create an export variable and in the parameter reference give the field reference of the field like this VBELN[], then this forms a structure parameter...
    Then place all your recorded SAPGUI/TCD with in Message/EndMessage Block, and make a rule as an expected message, something like this...
    MODE                    MSGID           MSGNR    MSGV1
    'E'               '/DBM/COMMON'     467     E_VBELN     
    MSGID & MSGNR might differ in your case use them accordingly, also check the previous log and make sure that the order number is MSGV1, if it is in MSGV2, place the variable E_VBELN in the MSGV2 field of the message Rule.
    This should generally fetch you all the order numbers...
    But in some situations it didnt work in my case, so here is the second solution...
    MESSAGE ( MSG_1 ).
    SAPGUI/TCD RECORDING
    ENDMESSAGE ( E_MSG_1 ).
    DO ( &TFILL ).
    IF ( E_MSG_1[&LPC]-MSGID = '/DBM/COMMON' AND E_MSG_1[&LPC]-MSGNR = 467 ).
         E_VBELN[V_COUNT]-TABLE_LINE = E_MSG_1[&LPC]-MSGV1.( V_COUNT Should also be declared, but as a local variable)
         V_COUNT = V_COUNT + 1.
    ENDIF.
    ENDDO.
    This was you will get all the order numbers in one variable, which you can access in any script while looping the varable based on its length..
    Check and modify accordingly.
    Hope this helps..
    Best regards,
    Harsha
    PS: award points if this answer helps solve your issue.

  • Read xml using xpath in java

    Hi ALL,
    I have a xml as follows:
    <AAA>
    <BBB>
    <CCC>xyz</CCC>
    <DDD>abc</DDD>
    </BBB>
    </AAA>
    Now using any of the java class, i just need read the value of "CCC" as follows:
    (i.e using xpath i need to read the value)
    String val = x.somemethod("/AAA/BBB/CCC");
    Thanks!

    In case you're curious - here's the dom4j equivalent of dvohra09's sample code.
    SAXReader saxReader = new SAXReader("org.apache.xerces.parsers.SAXParser");
    Document doc = saxReader.read(source); //Where source is your file, input source, input stream, reader, or url
    String value = doc.valueOf("//AAA/BBB/CCC"); //Result given the xml from OP = 'xyz'OK - not much difference with this simple example but if you haven't settled on an API, dom4j is worth looking at (IMHO).
    &#8734; brewman &#8734;

  • How can I make Firefox use another installed Java runtime version?

    For development purposes I have several Java runtime versions on my Windows 7 64 bit machine. I try to keep the number of installed JDKs and JREs to a minimum and I want Firefox to use JRE 1.7.0_21 (32 bit) since this came with a JDK version I am forced to use for another application.
    Firefox however uses JRE 1.6.0_31, and correctly reports this as insecure. It offers me the option to upgrade, but I do not want to download and install another JRE since I already have said JRE 1.7.0_21 installed. I would highly prefer to just be able to point Firefox to that JRE. I don't see an option to select another installed JRE however.
    I have already attempted to manually modify the pluginreg.dat file (I know, it says Do not edit...) by changing the JRE 1.6 entries to JRE 1.7, but upon restart my edits were overwritten and the old JRE was back. As a result I cannot view certain web sites (also corporate/internal) without having to switch to lesser browsers.
    Please let me know how I can make Firefox use the already installed JRE 1.7.

    Thank you for your response, cor-el. I was able to successfully add the JRE 1.7 plugin to Firefox by modifying the existing JRE 1.6 registry entries, but I would not recommend this procedure to users that are less confident in registry editing. Too bad there is not a more user friendly way to do this.
    Unfortunately the Java applet I'm trying to view is still not displayed. I've dug a bit deeper and found that the applet explicitly specifies an older JPI version (1.5.0_02). AFAIK Firefox cannot deal with this if its installed JPI (now 1.7.0_21) does not match the version requested. So either I'm going to have to dig up this older JPI version and install that too, or just switch to an alternative browser to be able to view this applet.

  • Using XPath from Java

    I've heard that you can use XPath from within Java instead of having to use it within XSLT, but I'm not sure what the syntax is?
    Does anyone know?
    Thanks,
    Oodi

    import org.apache.xerces.parsers.DOMParser;
    import org.apache.xpath.XPathAPI;
    DOMParser parser = new DOMParser();
    parser.parse(inputFile);
    doc = parser.getDocument();
    /* Search using XPATH */
    String xpath = "/XpathToSearch";
    NodeIterator nl = XPathAPI.selectNodeIterator(doc, xpath);
    HTH,
    Joe

  • How to retrieve Font info using JDK

    Hello there:
    I am wondering how I can find as much info about a font as I can using JDK. I can use
    GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts();
    to retrieve the Font object, and get its name, family, that's pretty much of it. There is getAttributes, but I am not sure how it works. If I want to know such info as the folder containing a particular font, the font's foundry, etc, I don't know how to get them.
    Anyone can point me to a right direction and maybe I can take from there.
    Thanks a lot,
    Sway

    thanks man, but i need more info about a font than that. Anyway I've found sun's API helpful to some extend.
    http://www.docjar.com/docs/api/sun/font/package-index.html

  • How to retrieving the content using Links

    Hi
    Please suggest me how to retrive content using link property.
    I have added link property to my Content. and i have added in internal resource path to the Link property.
    But my question is how access the page which is linked to my Content.
    How can i use it with anchor tag when i want show display the linked page content.
    what are tags to be used to retrive the linked content in the page.
    I found below line in CM documentation
    "These relationships are used by developers in their content queries when retrieving content to display in
    your portal."
    But i could found how to retrive.
    Genarally what technique we use to link an internal resource of our Content management
    thanks in advance
    Edited by: vamshi krishna on Jun 12, 2011 12:32 AM

    It sounds like there may be a misunderstanding about our link property feature.
    That feature is not for web hyperlinks. For that you can just use a string property. The links feature is for pointers to other pieces of content.
    (from: http://download.oracle.com/docs/cd/E13155_01/wlp/docs103/cm/contentTypesCm.html)
    "Using Link Properties
    You can create properties that allow content contributors to associate content items. Content contributors can link to content within the same or different repositories within the Virtual Content Repository. For example, if you have related content items that are stored in different folders, you can use content link properties to create relationships among content items. These relationships are used by developers in their content queries when retrieving content to display in your portal.
    Link properties can also be multi-valued to allow content contributors to link to multiple content items. For detailed instructions on adding a link property, see Define the Properties of a Content Type."
    Edited by: Chris Bales on Jun 13, 2011 2:56 PM

  • How to retrieve the node on which is running an ejb ?

              Hi all,
              I need to retrieve on which node is running and EJB that is deployed
              on the cluster. Since the cluster is made up of logical addresses on
              the same machine, I cannot get it with InetAddress.getHostName().
              It always return the phisical address of the machine.
              So I wonder if it's possible to retrieve with some Weblogic Api
              the node on which is running an ejb.....
              Thanks a lot
              Francesco
              

              You can get the server name by reading the system property "weblogic.Name" :
              System.getProperty("weblogic.Name")
              or using the wls Mbeans :
              import weblogic.management.MBeanHome;
              import weblogic.management.configuration.ServerMBean;
              String serverName = null;
              Context ctx = new InitialContext();
              MBeanHome mBeanH = (MBeanHome)ctx.lookup(MBeanHome.LOCAL_JNDI_NAME);
              java.util.Set serverMbeanSet = mBeanH.getMBeansByClass(weblogic.management.configuration.ServerMBean.class);
              Iterator iterat = serverMbeanSet.iterator();
              ServerMBean serverMb = (ServerMBean)iterat.next();
              serverName = serverMb.getName();
              Sergi
              "Francesco" <[email protected]> wrote:
              >
              >Hi all,
              >I need to retrieve on which node is running and EJB that is deployed
              >
              >on the cluster. Since the cluster is made up of logical addresses on
              >the same machine, I cannot get it with InetAddress.getHostName().
              >It always return the phisical address of the machine.
              >So I wonder if it's possible to retrieve with some Weblogic Api
              >the node on which is running an ejb.....
              >Thanks a lot
              >Francesco
              

  • Remove XML node using Xpath

    Hello,
    I'm using J Developer/SOA Suite 11.1.1.6.0 and BPEL 2.0
    I am trying to remove datetime nodes from xml, where the datetime value equals a certain value.  So far I have the following BPEL code:
      <assign name="RemoveEmptyDates">
          <extensionAssignOperation>
            <bpelx:remove>
              <bpelx:target>$GetNewHires_GetWrittenOffersReadyForUpload_OutputVariable.parameters//*[ . instance of xsd:dateTime and xsd:dateTime(.) = xsd:dateTime('0001-01-01T00:00:00')]</bpelx:target>
            </bpelx:remove>
          </extensionAssignOperation>
        </assign>
    I have tried multiple variations of the predicate, but I can't seem to figure it out.  Right now I am getting an error in J Developer that specifies it is expecting an "]" right after the "//*[." portion of the predicate.  Any ideas on this would be greatly appreciated.
    Thanks

    You can't use spaces.
    you have wrong this part of your text:
    [ . instance of xsd:dateTime and xsd:dateTime(.) = xsd:dateTime('0001-01-01T00:00:00')]
    check it.

  • How to retrieve string array using Session?

    Hi, I am having some problem retrieving string arrays through session.
    String personalData[] = new String[17];
    personalData = (String [])session.getValue("PersonalData");
    The coding above isn't working. Advise pls.. Thanks

    The getValue() method is deprecated - you should probably be using getAttribute.
    What about this code isn't working? Looks ok to me, as long as the "PersonalData" object in the session is a String[] it should work.
    Cheers,
    evnafets

Maybe you are looking for

  • Are There Solutions To Any Of These:

    PERSONAL Mavericks issues for me I notice so far, these may grow over time, so I will update the thread. Please note, this is not a complaint or rant (ha, though I am passionate about them and it may seem that way), but more of wondering if there is

  • How to remove header and footer from a "blank" page in Pages?

    Hi, In the top and the bottom there seems to be a header and footer, it noticeable when i do "mouse over". But when i right click i don't get the option to delete it. I cannot move it. I cannot move any other text or colums above it. ??? Help

  • 530 5.7.1 client was not authenticated

    OK, I am not in control of an exchange server.  My company uses GoDaddy for our exchange server.  I am an employee.  We use a software for contact management.  When I try to send emails to say a group of customers, it gives me the error 530 5.7.1 cli

  • Any way to find out names of outlined fonts in Illustrator file?

    I need to manipulate a logo that someone else created and she outlined the fonts prior to forwarding to me. From what I've seen online there's not an easy way to figure out what those fonts are. Just wondering if that's definitely the case... Thanks!

  • How to reinstall applications purchased in mac app store

    how to reinstall applications purchased in mac app store