473,326 Members | 2,102 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Problem while retrieving data based on condition

Hi All,

I have to get the values of "reading" and "value" elements of context
Person/Category/Group/ser.These values must be on condition
based,means I have to get the values of "reading" and "value" if
entity="abc" and value="1" , and entity= "def" and value="2" at the
Person/Category/Group/series/Key.

My xml source file is as follows.

<?xml version="1.0" encoding="UTF-8"?>
<Person>
<Category>
<Group>
<series>
<Key>
<Main entity="abc" value="1"></Main>
<Main entity="def" value="2"></Main>
</Key>
</series>
<ser>
<reading>age</reading>
<value>100</value>
</ser>
<ser>
<reading>height</reading>
<value>6</value>
</ser>
<ser>
<reading>weight</reading>
<value>80</value>
</ser>
</Group>
</Category>
</Person>
I am new to xml. I don't know how to write xpath for such a thing.
Please take a look at and give me suggestions how i should i approach
this problem.

Thanks and Regards,
Pathik

Apr 2 '07 #1
1 1784
Pathik wrote:
I have to get the values of "reading" and "value" elements of context
Person/Category/Group/ser.These values must be on condition
based,means I have to get the values of "reading" and "value" if
entity="abc" and value="1" , and entity= "def" and value="2" at the
Person/Category/Group/series/Key.

My xml source file is as follows.

<?xml version="1.0" encoding="UTF-8"?>
<Person>
<Category>
<Group>
<series>
<Key>
<Main entity="abc" value="1"></Main>
<Main entity="def" value="2"></Main>
</Key>
</series>
<ser>
<reading>age</reading>
<value>100</value>
</ser>
<ser>
<reading>height</reading>
<value>6</value>
</ser>
<ser>
<reading>weight</reading>
<value>80</value>
</ser>
</Group>
</Category>
</Person>
It is not clear to me which ser/reading and ser/value element you are
looking for as I don't see the relationship between the series/Key/Main
elements and those ser elements. Are you looking for all reading and
value elements if the document contains the Main elements meeting your
conditions on the attributes?
I am new to xml. I don't know how to write xpath for such a thing.
You need to learn about predicates which can be put into square brackets
e.g.
/Person/Category/Group
selects all Group elements with that path, then you can add a predicate
to filter them in square brackets e.g.
/Person/Category/Group[series/Key[Main[@entity = 'abc' and @value =
'1'] and Main[@entity = 'def' and @value = '2']]]
filters based on series/Key descendants for which another condition
holds, there is a Main child meeting your first attribute condition and
there is a Main child meeting the second attribute condition.
Then if you are looking for ser/reading desdendant elements of that
Group element you can add
/Person/Category/Group[series/Key[Main[@entity = 'abc' and @value =
'1'] and Main[@entity = 'def' and @value = '2']]]/ser/reading

--

Martin Honnen
http://JavaScript.FAQTs.com/
Apr 2 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: StBond | last post by:
Hi everyone, I am new to Access and Visual Basic so things my be getting across a bit cloudy. I only started using VB for one week. I am having a little problem with the database that I am...
5
by: Mark Broadbent | last post by:
Does anyone know why some genius decided that data based breakpoints are not supported in C#/ vb.net debugging? Is there some technical reason Or has it been done to make breakpointing more...
0
by: Chris Ericoli | last post by:
Hi, I am working with an 'in session' ado dataset with an asp.net application. My dataset is comprised of two tables, one of which maintains a few calculated datacolumns. For some reason these...
9
by: Tony | last post by:
I have an operator== overload that compares two items and returns a new class as the result of the comparison (instead of the normal bool) I then get an ambiguous operater compile error when I...
22
by: MP | last post by:
vb6,ado,mdb,win2k i pass the sql string to the .Execute method on the open connection to Table_Name(const) db table fwiw (the connection opened via class wrapper:) msConnString = "Data Source="...
11
by: Bob Rock | last post by:
Hello, I have an array of strings and need to find the matching one with the fastest possible code. I decided to order the array and then write a binary search algo. What I came up with is the...
1
by: makhan | last post by:
Hi I am using my c based application using libpq to connect to postgresql. I have a table called light. I want to collect the values of the table light into a varible condition so that I can...
36
by: beebelbrox | last post by:
Hi, I am new VB programming in Access and I am requesting help with the following code. WIndows OS MSaccess 2003 This code is attached to an unbound form that will display a specific recordset...
9
ADezii
by: ADezii | last post by:
One question which pops up frequently here at TheScripts is: 'How do I retrieve data from a Recordset once I've created it?' One very efficient, and not that often used approach, is the GetRows()...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.