473,396 Members | 1,785 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,396 software developers and data experts.

select nodes with child node A and child node B

I have an XML document that has multiple childe nodes like the one at
the end of this message

What syntax would I use with selectNodes to select all viewentry nodes
that have an

entrydata child node with a name attribute equal to
"CourseOrMeetingName"
that has a text childe node with the text Course ABC

AND that also have an

entrydata child with a name attribute equal to Start Date
that has a datetime child node with the text 20070110

I was trying something like

//viewentry[ (entrydata[@name='CourseOrMeetingName'][text='Course
ABC']) and (entrydata[@name='StartDate'][datetime='20070110'])]"

<viewentry position="1" unid="E5FE575692CAB4CD852572140052F751"
noteid="893A" siblings="24">
<entrydata columnnumber="0" name="CourseOrMeetingName">
<text>Course ABC</text></entrydata>
<entrydata columnnumber="1" name="StartDate">
<datetime>20070110</datetime></entrydata>
<entrydata columnnumber="2" name="City">
<text>West chester</text></entrydata>
<entrydata columnnumber="3" name="FirstName">
<text>Joe</text></entrydata>
<entrydata columnnumber="4" name="MiddleName">
<text></text></entrydata>
<entrydata columnnumber="5" name="LastName">
<text>Blow</text></entrydata>
</viewentry>

Thanks,

Glenn

Nov 1 '06 #1
1 1894
gp****@yahoo.com wrote:
//viewentry[ (entrydata[@name='CourseOrMeetingName'][text='Course
ABC']) and (entrydata[@name='StartDate'][datetime='20070110'])]"
Works just fine when I try it on your sample fragment, using Xalan:

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:copy-of select="//viewentry[
(entrydata[@name='CourseOrMeetingName'][text='Course ABC']) and
(entrydata[@name='StartDate'][datetime='20070110'])]"/>
</xsl:template>
</xsl:stylesheet>

Output is
<?xml version="1.0" encoding="UTF-8"?><viewentry position="1"
unid="E5FE575692CAB4CD852572140052F751" noteid="893A" siblings="24">
<entrydata columnnumber="0" name="CourseOrMeetingName">
<text>Course ABC</text></entrydata>
<entrydata columnnumber="1" name="StartDate">
<datetime>20070110</datetime></entrydata>
<entrydata columnnumber="2" name="City">
<text>West chester</text></entrydata>
<entrydata columnnumber="3" name="FirstName">
<text>Joe</text></entrydata>
<entrydata columnnumber="4" name="MiddleName">
<text/></entrydata>
<entrydata columnnumber="5" name="LastName">
<text>Blow</text></entrydata>
</viewentry>

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Nov 1 '06 #2

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

Similar topics

5
by: Chris | last post by:
Hi, Maybe I've got a strange question. I've got a XML document (main.xml) with several nodes. Additional I've another XML docuement (role.xml), with allowed nodes. In a XSL-File I just would...
3
by: Dinesh_GR | last post by:
Hi all, I have many parent tags and many child tags under the respective parent.. in an XML file. On the click of a button the application should pick up the one parent and the corresponding...
1
by: George W. | last post by:
Okay, I'm a C#/XML newbie, and I've been wrestling with this for a while now, checked dotnet sites, articles, MSDN Library, etc. and haven't been able to determine why this is happening. I have...
6
by: Paul J Lay | last post by:
I am using the XmlDocument Select Nodes method and it seems to work OK except that it returns embedded nodes in the collection when I only want the nodes that are not embedded. For example I have...
1
by: Ryo | last post by:
Hello !!! I have a treeview with checkbox to select element. The problem is that i can't found how to automatically select the childnodes the checked node. Someone know how to do that ? Thanks.
4
by: MA | last post by:
Hi, How to access the total number of child nodes from a parent node. For example, I would like to get the total number of child nodes from <parent1and <parent2node. The SelectNodes method...
2
by: GreggaR0und | last post by:
Hello; I'm trying to iterate through the sub nodes of a child node, but I'm getting a compile error on the nested For...Next expression saying it is invalid. Using the below code, the HasChild()...
1
by: manjunathatv | last post by:
I am trying to select a set of nodes in an xml document. (like xmlDocument.SelectNodes(xPath)) but the nodes are at different levels. so am not getting all the node with that node name in all the...
0
by: divya1949 | last post by:
Create a windows c# application which will Read a xml file and populate nodes in the treeview. 1 On selection of treenode display the child nodes of that node in listview control 2. ...
5
by: SkipSailors | last post by:
I have some XML that I want to transform to some XML: <element> <child> <grandchild> otherWord </grandchild> <grandchild> triggerExclusion...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
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...
0
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,...
0
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...
0
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...
0
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,...

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.