473,587 Members | 2,508 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1804
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
3414
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 working on. I am working with MS Access 2002. And I am having a problem with one of my charts. I will explain how everything is laid out then go...
5
5090
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 fustrating than ever? --
0
3135
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 datacolumns do not trigger their expression when other columns from which the expressions are derived are updated. Below is a basic example of what...
9
2371
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 attempt to check to see if the object is null: "The call is ambiguous between the following methods or properties: 'TestObject.operator...
22
12449
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=" & msDbFilename moConn.Properties("Persist Security Info") = False moConn.ConnectionString = msConnString moConn.CursorLocation = adUseClient...
11
2416
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 following. I noticed that if I set: int upper = strings.GetUpperBound(0); I never match the last element in the array (i.e. "iii")
1
1646
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 check this condition if(condition ==3) and do some operation depending on this operation. Can someone guide me how this can be done. Regards MAK
36
4766
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 based in information passed to the form from another form. The problem I am having is that for each of the case statements the proper records (values...
9
35418
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() Method of the Recordset Object. This Method varies slightly from DAO to ADO, so for purposes of this discussion, we'll be talking about DAO Recordsets....
0
8349
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7974
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8221
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5719
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5395
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3845
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2364
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1455
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1192
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.