I have a query where i need to look for a value of a lower level xml
element based on the value of a parent element existing first. Here is
a simple example of the xml
<S3Client>
<Buttons>
<Button>Activit y
<RestrictedClie ntType>
<ClientType>0 2</ClientType>
</RestrictedClien tType>
</Button>
...
</Buttons>
</S3Client>
Here is my query, I am trying see if ClientType '02' exists when the
Button element has a value of "Activity". I wanted to do this in one
xpath query. Any help would be appreciated.
/Security/S3Client/Buttons[Button='Activit y']/
RestrictedClien tType[ClientType='02']
Tim 5 2435
* tschulken wrote in microsoft.publi c.dotnet.xml:
>I have a query where i need to look for a value of a lower level xml element based on the value of a parent element existing first. Here is a simple example of the xml
<S3Client>
<Buttons>
<Button>Activit y
<RestrictedClie ntType>
<ClientType>0 2</ClientType>
</RestrictedClien tType>
</Button>
...
</Buttons> </S3Client>
Here is my query, I am trying see if ClientType '02' exists when the Button element has a value of "Activity". I wanted to do this in one xpath query. Any help would be appreciated. /Security/S3Client/Buttons[Button='Activit y']/ RestrictedClie ntType[ClientType='02']
For example:
//ClientType[ . = '02' and
ancestor::Butto n[ normalize-space() = 'Activity' ]
or
/S3Client/Buttons/Button[ normalize-space() = 'Activity' ]/
RestrictedClien tType/ClientType[ . = '02' ]
Your expression is basically correct, but you missed the space
characters in the <Buttonelemen t.
--
Björn Höhrmann · mailto:bj****@h oehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
On Mar 15, 5:21 pm, Bjoern Hoehrmann <bjo...@hoehrma nn.dewrote:
* tschulken wrote in microsoft.publi c.dotnet.xml:
I have a query where i need to look for a value of a lower level xml
element based on the value of a parent element existing first. Here is
a simple example of the xml
<S3Client>
<Buttons>
<Button>Activit y
<RestrictedClie ntType>
<ClientType>0 2</ClientType>
</RestrictedClien tType>
</Button>
...
</Buttons>
</S3Client>
Here is my query, I am trying see if ClientType '02' exists when the
Button element has a value of "Activity". I wanted to do this in one
xpath query. Any help would be appreciated.
/Security/S3Client/Buttons[Button='Activit y']/
RestrictedClien tType[ClientType='02']
For example:
//ClientType[ . = '02' and
ancestor::Butto n[ normalize-space() = 'Activity' ]
or
/S3Client/Buttons/Button[ normalize-space() = 'Activity' ]/
RestrictedClien tType/ClientType[ . = '02' ]
Your expression is basically correct, but you missed the space
characters in the <Buttonelemen t.
--
Björn Höhrmann · mailto:bjo...@h oehrmann.de ·http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 ·http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 ·http://www.websitedev.de/- Hide quoted text -
- Show quoted text -
Bjorn,
That makes sense but it seems that I am having trouble getting it to
work. Since the <RestrictedClie ntTypewas added as a child node of
Button, seems that the first part of my query doesn't work. I guess I
am used to parent nodes just having no values or maybe just attributes
but seems that since Button has a value of "Activity" and then the
child node, does querying for the Activity Text change? Here is an
example, before <RestrictedClie ntTypewas added, this xpath query
would work fine:
_xmlDocument.Se lectSingleNode( "/Security/S3Client/Buttons/
Button['Activity']" );
Now that query does not work, any ideas?
Thanks.
Tim
* tschulken wrote in microsoft.publi c.dotnet.xml:
><S3Client>
<Buttons>
<Button>Activit y
<RestrictedClie ntType>
<ClientType>0 2</ClientType>
</RestrictedClien tType>
</Button>
...
</Buttons> </S3Client>
Here the content of the <Buttonelemen t is this:
1. the word "Activity" followed by
a line feed character followed by space characters
2. the RestrictedClien tType element
3. a line feed character followed by space characters
I do not know whether the code above has been pretty printed for
readability, or whether it reflects what is actually in the tree
in memory, but assuming this is how it is in memory your original
.... Button='Activit y' ... would not work as that would match if
the content was just 'Activity'.
>That makes sense but it seems that I am having trouble getting it to work. Since the <RestrictedClie ntTypewas added as a child node of Button, seems that the first part of my query doesn't work. I guess I am used to parent nodes just having no values or maybe just attributes but seems that since Button has a value of "Activity" and then the child node, does querying for the Activity Text change? Here is an example, before <RestrictedClie ntTypewas added, this xpath query would work fine: _xmlDocument.S electSingleNode ( "/Security/S3Client/Buttons/ Button['Activity']" );
I am not sure whether this is a typo, but this does not do what you
want at all. The string literal 'Activity' is converted to a boolean
(true) so this would select the first 'Button' element that has the
ancestors Buttons, S3Client, Security, in that order. You could also
write
/Security/S3Client/Buttons/Button['HelloWorld']
and the result would be the same.
>Now that query does not work, any ideas?
I do not see a reason why this would happen.
--
Björn Höhrmann · mailto:bj****@h oehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
On Mar 15, 9:30 pm, Bjoern Hoehrmann <bjo...@hoehrma nn.dewrote:
* tschulken wrote in microsoft.publi c.dotnet.xml:
<S3Client>
<Buttons>
<Button>Activit y
<RestrictedClie ntType>
<ClientType>0 2</ClientType>
</RestrictedClien tType>
</Button>
...
</Buttons>
</S3Client>
Here the content of the <Buttonelemen t is this:
1. the word "Activity" followed by
a line feed character followed by space characters
2. the RestrictedClien tType element
3. a line feed character followed by space characters
I do not know whether the code above has been pretty printed for
readability, or whether it reflects what is actually in the tree
in memory, but assuming this is how it is in memory your original
... Button='Activit y' ... would not work as that would match if
the content was just 'Activity'.
That makes sense but it seems that I am having trouble getting it to
work. Since the <RestrictedClie ntTypewas added as a child node of
Button, seems that the first part of my query doesn't work. I guess I
am used to parent nodes just having no values or maybe just attributes
but seems that since Button has a value of "Activity" and then the
child node, does querying for the Activity Text change? Here is an
example, before <RestrictedClie ntTypewas added, this xpath query
would work fine:
_xmlDocument.Se lectSingleNode( "/Security/S3Client/Buttons/
Button['Activity']" );
I am not sure whether this is a typo, but this does not do what you
want at all. The string literal 'Activity' is converted to a boolean
(true) so this would select the first 'Button' element that has the
ancestors Buttons, S3Client, Security, in that order. You could also
write
/Security/S3Client/Buttons/Button['HelloWorld']
and the result would be the same.
Now that query does not work, any ideas?
I do not see a reason why this would happen.
--
Björn Höhrmann · mailto:bjo...@h oehrmann.de ·http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 ·http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 ·http://www.websitedev.de/
Bjorn,
Yes, what i had was a typo and I apologize. The xpath query should be
"/Security/S3Client/Buttons[Button='Activit y']". This used to work for
all Button lookups and now that I added the Child Node for the
"Activity" button, it doesn't work on that one (but still works for
others since they don't have children). Is there a way for a single
query to be used for both scenarios?
Tim
On Mar 16, 8:40 am, "tschulken" <tschul...@gmai l.comwrote:
On Mar 15, 9:30 pm, Bjoern Hoehrmann <bjo...@hoehrma nn.dewrote:
* tschulken wrote in microsoft.publi c.dotnet.xml:
><S3Client>
<Buttons>
<Button>Activit y
<RestrictedClie ntType>
<ClientType>0 2</ClientType>
</RestrictedClien tType>
</Button>
...
</Buttons>
></S3Client>
Here the content of the <Buttonelemen t is this:
1. the word "Activity" followed by
a line feed character followed by space characters
2. the RestrictedClien tType element
3. a line feed character followed by space characters
I do not know whether the code above has been pretty printed for
readability, or whether it reflects what is actually in the tree
in memory, but assuming this is how it is in memory your original
... Button='Activit y' ... would not work as that would match if
the content was just 'Activity'.
>That makes sense but it seems that I am having trouble getting it to
>work. Since the <RestrictedClie ntTypewas added as a child node of
>Button, seems that the first part of my query doesn't work. I guess I
>am used to parent nodes just having no values or maybe just attributes
>but seems that since Button has a value of "Activity" and then the
>child node, does querying for the Activity Text change? Here is an
>example, before <RestrictedClie ntTypewas added, this xpath query
>would work fine:
>_xmlDocument.S electSingleNode ( "/Security/S3Client/Buttons/
>Button['Activity']" );
I am not sure whether this is a typo, but this does not do what you
want at all. The string literal 'Activity' is converted to a boolean
(true) so this would select the first 'Button' element that has the
ancestors Buttons, S3Client, Security, in that order. You could also
write
/Security/S3Client/Buttons/Button['HelloWorld']
and the result would be the same.
>Now that query does not work, any ideas?
I do not see a reason why this would happen.
--
Björn Höhrmann · mailto:bjo...@h oehrmann.de ·http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 ·http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 ·http://www.websitedev.de/
Bjorn,
Yes, what i had was a typo and I apologize. The xpath query should be
"/Security/S3Client/Buttons[Button='Activit y']". This used to work for
all Button lookups and now that I added the Child Node for the
"Activity" button, it doesn't work on that one (but still works for
others since they don't have children). Is there a way for a single
query to be used for both scenarios?
Tim- Hide quoted text -
- Show quoted text -
Seems that having the child nodes alters the text for the Button so in
the case of the 'Activity' Button, its text is Activity02. Can I just
specify that I don't want to consider the child nodes text at this
point? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: 0wl |
last post by:
Hi,
I am trying to get the value of child from
xmlstr = """<p:root xmlns:p="http://tempuri.org/string"><p:child
DataType="String">Hellpppp</p:child></p:root>"""
using
doc=parseString(xmlstr)
nodeList = xml.xpath.Evaluate("/p:root/p:child/text()", doc)
|
by: Terry P |
last post by:
Are there any tools (java classes, tag libraries) which can translate
xpath statements into a SQL query?
Given an xpath query which has a predicate that filters node values or
attributes, I want help constructing the Where clause of a SQL
statement that will mirror the expressions and functions contained in
the predicate.
Such a tool may require an XML to DB mapping or it would need to make
assumptions about the structure of the...
|
by: gfrommer |
last post by:
Hello Everyone,
I'm writing a server in java, and I want the clients to pass me an
XPath query. I want the XPath queries to be in a specific format
though, I'm pretty sure it's valid but I want your help.
We have several -top level- documents that the user is allowed returned
to them from the query. We don't want them grabbing subchunks of the
XML without that being encased in one of the allowed top documents. For
example, "Person" is...
|
by: Ot |
last post by:
I posted this to the wrong group. It went to m.p.dotnet.languages.vb.
Ooops.
--------------------------------------------------------------------
I have this tiny problem. I have learned that an xpath expression can be
bounded by either single or double quotation marks.
But sometimes I want to search for a title containing both a single and
double quote. Any way to do this?
|
by: mel_dev |
last post by:
All,
I'm brand new to XML and have been given a deadline to deliver some new
functionality part of which requires stepping through an xml doc. I
have hit a wall with the way I've structured an xpath query to select
nodes from the xml and would be most appreciative of some assistance.
The beginning of the xml doc looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<ClliOutput xmlns="http://hobb.catalina.telcordia.com"
| |
by: Michael C# |
last post by:
OK, here's the deal. I have a small XML file that represents a small
database table. I load it into a System.XML.XMLDocument. So far so good.
I run an XPath query against it to retrieve all the field names. Everything
there works fine.
Here's my XML Document:
<?xml version="1.0" standalone="yes" ?>
<DataSet1 xmlns="http://www.tempuri.org/DataSet1.xsd">
<tblItem>
|
by: Gnic |
last post by:
Hi ,
I have an XmlDocument instance, I want to find a node in the xml, but I
don't know it's path until runtime, for example
<aaa>
<bbb name="x"/>
<aaa attr="y">
<ccc>sometext</ccc>
</aaa>
|
by: dotnetnoob |
last post by:
i would like to know how i can build xpath expression dynamiclly. let's say i
have a following xml file:
<EventEnrollment InstanceNumber = "675">
<EventSource>
<ObjectReference ObjectKey="xxxxx">
..
..
..
<EventEnrollment InstanceNumber = "676">
|
by: Jason Mobarak |
last post by:
Hello --
I'm attempting to get a handle on how to do xpath queries with
System.Xml -- so far the biggest hurdle has been how to deal with a
default namespace. If I use the test xml:
<?xml version="1.0" encoding="utf-8" ?>
<thing xmlns="urn:thing-schema-v1">
<foo>foo thing</foo>
<bar>bar thing</bar>
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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,...
| |
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,...
|
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...
|
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...
|
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...
|
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |