Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4015722
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:39:13+00:00 2026-05-20T09:39:13+00:00

I have a xml data as below: <list> <com.domain.Products> <cla__id> <cname>class1</cname> <id>1</id> </cla__id> <name>pname1</name>

  • 0

I have a xml data as below:

<list>
    <com.domain.Products>
        <cla__id>
          <cname>class1</cname>
          <id>1</id>
        </cla__id>
        <name>pname1</name>
        <id>1</id>
    </com.domain.Products>

    <com.domain.Products>
        <cla__id reference="../../com.domain.Products/cla__id"/>
        <name>pname2</name>
        <id>2</id>
    </com.domain.Products>
</list>

I want to use the xpath to get the value for cname node (the value is ‘class1’), while for the second com.domain.Products node, it just has a reference to the cla__id node, which is exactly the same as the one of first com.domain.Products node…

So, the cname for the second com.domain.Products node is actually the same as first com.domain.Products node, both are ‘class1’, but if I use cla__id/cname xpath to get the value, I can only get it correctly for the first com.domain.Products node, second com.domain.Products node will only have a blank value, which is wrong.

How to achieve the correct result? Thanks a lot.

attach: My current smartgwt java code doing it this way:

......
private ProductsDS(String id) {
String recordName = "com.domain.Products";
setID(id);
setDataFormat(DSDataFormat.XML);
setRecordXPath("//" + recordName);

DataSourceField pkField = new DataSourceField("id", FieldType.INTEGER, "id");
pkField.setHidden(true);
pkField.setPrimaryKey(true);
DataSourceField claIdField = new DataSourceField("cla__id/cname", FieldType.TEXT, "classtype");
claIdField.setValueXPath("cla__id/cname");
......

ps: just re-edit twice to make the post better..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T09:39:13+00:00Added an answer on May 20, 2026 at 9:39 am

    It is not possible in XPath 1.0 and XPath 2.0 to perform dynamic (not contained in the XPath expression, but generated) XPath expressions.

    Therefore, it is not possible to dynamically evaluate a reference to an element, embedded in another XML element, where the reference is an XPath expression.

    Proposed solution: Provide a new way to uniquely identify an element (such as giving it a unique id attribute) and use the value of this attribute as the reference to the element:

    <list>
        <com.domain.Products>
            <cla__id>
                <cname>class1</cname>
                <id>1</id>
            </cla__id>
            <name>pname1</name>
            <id>1</id>
        </com.domain.Products>
        <com.domain.Products>
            <cla__id reference="1"/>
            <name>pname2</name>
            <id>2</id>
        </com.domain.Products>
    </list>
    

    Then, the cname value for the com.domain.Products element having id of 2 is:

    /*/*
      [id
      = 
       /*/*[id=2]/cla__id/@reference]
                               /cla__id/cname/text()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I data in the below format (List of HashMap's) {TeamName=India, Name=Sachin, Score=170} {TeamName=India, Name=Sehwag,
I have a XML file like the below: <clients> <client> <id>YYYY</id> <name>XXXX</name> <desc>ZZZZ</desc> <trade_info>
I have a data stored in a xml column and need a comma-separated list
I have a WPF tree (bound to XML data). An excerpt is given below:
I have some xml data contained in three files (Database.xml, Participants.xml, and ConditionTokens.xml). I
I have an xml data file and I want to populate a listview in
I have grabbed some XML data using this piece of jQuery: $.ajax({ type: POST,
If I have the xml/html data to post we need to encode the data
I am using PhoneGap, jQuery mobile in Xcode. I have a local xml (data.xml)
I have to import some XML data into my app. Now I open a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.