473,698 Members | 2,243 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to write XPATH with conditions,

14 New Member
<?xml version="1.0" encoding="utf-8"?>
<CategoryList >
<Category ID="01" Title="One">
</Category>
<Category ID="03" Title="Three">
</Category>
<Category ID="04" Title="Four">
<Style Color="Red" >
<Car Name="R"/>
</Style>
<Style Color="Blue" >
<Car Name="B"/>
</Style>
<Style Color="White" >
<Car Name="W"/>
</Style>
</Category>
<Category ID="02" Title="Two">
</Category>
</CategoryList>


"/CategoryList/Category[@ID=01]/Title"
Present im using this xpath to find "Title" value where ID=01

1? Suppose ID=01 is not( i mean 01 is not a value for ID in Xml file) available , then wt will happen and how to handle that.

and i want write Xpath ( which includes more than 2 r 3 conditions) based on conditions

2? suppose ID=4 and Color=Blue then i have find value for "Car" ( two conditions)then how to write XPATH for this
* hre we hav different values for both ID & Color,

Thanks,
Ajay
Dec 14 '07 #1
1 4196
Dököll
2,364 Recognized Expert Top Contributor
<?xml version="1.0" encoding="utf-8"?>
<CategoryList >
<Category ID="01" Title="One">
</Category>
<Category ID="03" Title="Three">
</Category>
<Category ID="04" Title="Four">
<Style Color="Red" >
<Car Name="R"/>
</Style>
<Style Color="Blue" >
<Car Name="B"/>
</Style>
<Style Color="White" >
<Car Name="W"/>
</Style>
</Category>
<Category ID="02" Title="Two">
</Category>
</CategoryList>


"/CategoryList/Category[@ID=01]/Title"
Present im using this xpath to find "Title" value where ID=01

1? Suppose ID=01 is not( i mean 01 is not a value for ID in Xml file) available , then wt will happen and how to handle that.

and i want write Xpath ( which includes more than 2 r 3 conditions) based on conditions

2? suppose ID=4 and Color=Blue then i have find value for "Car" ( two conditions)then how to write XPATH for this
* hre we hav different values for both ID & Color,

Thanks,
Ajay
Are you trying to do this using VB 6.0?
Dec 16 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1821
by: bdinmstig | last post by:
I am building various framework components for my team to use in development, and one of those components is a Facade for reading/writing user preferences. The idea is that preference settings are stored in a free-format XML document (in memory for the life of the session) and persisted to a database (as free text) on exit. I have taught my developers the basics of XPath, however I don't want to have to review XMLDOM code all over the...
1
6822
by: bdinmstig | last post by:
I refined my attempt a little further, and the following code does seem to work, however it has 2 major problems: 1. Very limited support for XPath features Basic paths are supported for elements, attributes, ".", and "..", plus also the "" predicate format is supported - however, only one predicate per path step is supported, and expr must be a relative path. 2. Poor performance
0
1240
by: Anna | last post by:
Hi all. I have a rather odd question: I need to construct an XPath, where one of the conditions is not() on other XPath. SOmething like this: //img)] - image that is not image with alt attribute. Of course, in this case I could just say //img, but my XPaths are generated automatically, so I have to have it in the form of XPath1. //*, for example, will choose all the nodes that are not img nodes.
14
12175
by: inquirydog | last post by:
Hi- One frusterating thing for me with xsl is that I don't know how to make xslt throw some sort of exception when a value-of path does not exist. For instance, suppose I have the following line in xslt <xsl:value-of select="/blah/q" /> and my xml document does not have a node /blah/q. The output would
0
1763
by: Ketan | last post by:
Hello, I am looking for a java-based xpath parser, that will enable me parse a string containing an xpath expression into steps, predicates, conditions etc. sample expressions: a/b/c, a/b/c etc. I have looked at a couple and didn't really find what I wanted.. Some
8
2194
by: Jean-François Michaud | last post by:
Who in the name of #%@! thought this one out?? I noticed this behavior when trying to debug a problem I was having. I used this logical expression and some XPATH in a specific sequence of instructions that allow me to transform a CALS table model into our own specific table model and I used this expression: <xsl:if test="self::node()=../CELL and self::node()">...
5
50576
by: jorgedelgadolopez | last post by:
Hi all, I am using the xpathnavigator evaluate function on .net (xpath 1 right?). Now I need to expand the code to do multiple contains, compare dates (such as 'before', 'between' and 'after'), and so on. This is the thought: //person
2
2219
by: sam | last post by:
I use in my csharp code this xml: <doc> <item Id="1"> <item>1</item> </item> <item Id="1"> <item>2</item> </item> <item Id="2"> <item>A</item>
0
8608
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9161
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8897
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8867
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7732
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6522
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3050
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

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.