Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / General MS InfoPath Questions / March 2005

Tip: Looking for answers? Try searching our database.

SelectNodes Query

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rama - 03 Mar 2005 18:33 GMT
I am trying to use selectnodes on parentNode of the context Node and it is
not returning the correct resull. Heres my XML

1  <a>
2   <fields>
3     <field  name='test1' >
4       <b>
5           <a>
6                 <fields>            // This is parent Node
7                 <field   name='test1' >    //  Context Node
8                 </fields>
9           </a>
10      </b>
11    <field  name='test2' >
12   </fields>
13 </a>

My Context node is  node corresponding to line 7. The following code returns
2 nodes instead of 1 ,  nodes corresponding to line 3 and line 7
      CurrentNode.parentNode.selectNodes("//fields/field[@name='test1']")

What is it that I am missing ?  Any help would be appreciated.

Thanks,

Rama
Steve van Dongen [MSFT] - 05 Mar 2005 00:08 GMT
>I am trying to use selectnodes on parentNode of the context Node and it is
>not returning the correct resull. Heres my XML
[quoted text clipped - 18 lines]
>
>What is it that I am missing ?  Any help would be appreciated.

It is returning the correct result.  Perhaps you should tell us which
node(s) you wanted it to return.

Regards,
Steve
--
Please post questions to the newsgroup; everyone benefits.
This posting is provided "AS IS" with no warranties, and confers no rights.
Sample code subject to http://www.microsoft.com/info/cpyright.htm
Rama - 07 Mar 2005 15:19 GMT
Steve,
Since my context node is <field   name='test1' >  , I am trying to go one
step back to the parent node; the xml corresponding to the parent nopde
should  be as follows  :
  <fields>      
        <field   name='test1' >  // my context node
        <field  name= 'test11'>
        <field name ='test1'2 >
 </fields>

My objective is to find out if attribute 'name'  for nodes 'field'  is
unique within its parent node 'fields'. My Xml DOM also contain 'field' node
at some other levels and  it is somehow returning every node named field  
within the document.
I hope, i have  made my problem clear, let me know if i further need to
clarify anything.

Thanks,

Rama

> >I am trying to use selectnodes on parentNode of the context Node and it is
> >not returning the correct resull. Heres my XML
[quoted text clipped - 28 lines]
> This posting is provided "AS IS" with no warranties, and confers no rights.
> Sample code subject to http://www.microsoft.com/info/cpyright.htm
Will Lawrence - 07 Mar 2005 14:10 GMT
Because you are using a relative search query that finds any node named
"fields" with the XPPATH query "//fields/field[@name='test1']"

To get the parent node, you'll need to use the absolute path which starts
with the root node.  In your case, you'll want to use "/a/fields/field
[@name='test1']".

You may also want to look at the function selectSingleNode().
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.