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

  • SEARCH
  • Home
  • 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 6909657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:43:01+00:00 2026-05-27T08:43:01+00:00

Lets say I have an xml structure like this: <s> <a> <b id=myid>value1</b> <c

  • 0

Lets say I have an xml structure like this:

<s>
  <a>
    <b id="myid">value1</b>
    <c id="test">val1</c>
    <c id="test2">valX</c>
  </a>
  <g>
    <d id="myid">value2</d>
    <e id="test">val2</e>
  </g>
  <i id="myid">value3</i>
  <j id="test">val3</j>
</s>

Notice the tag names are not important. Only the attribute “id” and the textvalue of the node.

The xpath query will be used to check if the values exists, so I can return the whole XML. This xpath query is done on a whole set of different XML strings returning those who match.

Now I want to use xpath to verify if either:

("myid"="value1" AND "test"="val1") OR ("myid"="value2" AND "test"="val2")

How would I write this as an XPath string? “val1” has to be on the same level in the XML as “value1”. The same goes for “val2” with “value2”, and “val3” and “value3”

I need to write this in a way that makes it easy to expand upon as this XPath query will be generated by code.

The input query for the generator will be on a AND/OR with “(” and “)”. So I need to make a parser to create the XPath from this.

Examples:

q1: ("myid"="value1" AND "test"="val1") OR ("myid"="value2" AND "test"="val2") OR 
 ("myid"="value3" AND "test"="val3")
q2: ("myid"="value1" AND "test"="val1") AND ("myid"="value2" AND "test"="val2") 
q3: "myid"="value1" AND ("test"="val1" OR "test"="valX") 

What I need is a way to make sure all the @id checks are performed on the same XML subset. So in this XML the check should either get a match from all the @id’s directly below the S-node, or a match from all the @id’s directly below the A-node, or a match from all @id’s directly below the G-node. (and all other similar nodes)

If any match is done, I can return the XML. I do not know how many levels there are as the xml is very generic with the one rule that each value node has an @id attribute with the value name.

"myid"="value1" AND "test"="val1" should return a match.
"myid"="value2" AND "test"="val2" should return a match.
"myid"="value3" AND "test"="val3" should return a match.
"myid"="value3" AND "test"="val1" should NOT return a match.
"myid"="value2" AND "test"="val3" should NOT return a match.

etc.

This might be simple. But I have not found a way to get this done. Can anyone help me with this. Any hints are appreciated.

I hope I have made this understandable.

How would you write the same where upper or lower case is ignored. Like this?

//*[ *[@id [lower-case(.)="myid"] [lower-case(..)="value1"] ] and *[@id [lower-case(.)="test"] [lower-case(..)="val1"] ] ]

or is there a better way. The values are pre .ToLower()’ed.

  • 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-27T08:43:01+00:00Added an answer on May 27, 2026 at 8:43 am

    I think you are looking for an expression like that :

    //*[ *[@id ='myid'] = 'value1' and *[@id ='test'] = 'val1']
    

    The result will be all the elements that have at least two children with an id attribute with the following constraints :

    • one of the children must have an id attribute value that is equal to myid, the value of the element has to be value1.
    • one of the children must have an id attribute value that is equal to test, the value of the element has to be val1.

    Then you can add and or or as you wish. For example :

    //*[ (*[@id ='myid'] = 'value1' and *[@id ='test'] = 'val1') or (*[@id ='myid'] = 'value2' and *[@id ='test'] = 'val2')]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Lets say you have an XML like like this: <data> <messages> <message name=Person id=P>
Let's say I have xml structure like this <root> <element>some content</element> <element>some content 2</element>
Lets say I have a xslt stylesheet like the following: <?xml version=1.0 encoding=utf-8?> <xsl:stylesheet
I'm trying to format a table from XML. Lets say I have this line
Let's say I have some XML like this <channel> <item> <title>This is title 1</title>
I have an XML doc with a structure like this: <Book> <Title title=Door Three/>
Lets say I have this xml: <categories> <category text=Arts> <category text=Design/> <category text=Visual Arts/>
Lets say I have this XML: <images> <photo> <thumbImg>images/thumbs/002.jpg</thumbImg> <filename>002</filename> </photo> <photo> <thumbImg>images/thumbs/008.jpg</thumbImg> <filename>008</filename>
Lets say I have XML that looks like so (and assume I can't alter
Lets say i have this XML file: <attributes> <units> <civilians> <unit> <name>Settler</name> <stats> <attack>26</attack>

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.