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 / September 2004

Tip: Looking for answers? Try searching our database.

selectSingleNode Method (and Repeating Table)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Juli V. - 31 Aug 2004 03:41 GMT
Can somebody, please, explain me the way of workin this method!

For example, in some cases (help examples) I can see syntax like this:

objXMLNode = XDocument.DOM.selectSingleNode("/employees/employee"); //
HERE!!!
XDocument.View.SelectNodes(objXMLNode);
objXMLNodes = XDocument.View.GetSelectedNodes();
if (objXMLNodes.Count > 0){
     XDocument.UI.Alert(objXMLNodes(0).nodeName + "\n\n" +
objXMLNodes(0).text);
}

And in some another:

nodeselfilename =
XDocument.DOM.selectSingleNode("/my:myFields/my:FileName").text;  //
ANOTHER!!!
XDocument.SaveAs(nodeselfilename);

So what is the point?? I can't catch it!

And now my problem:
I have Repeating Table, and want to extract the same values from text-field,
for example, "task" (it repeats several times)
So how should I achieve it? To get array, or something, with the values from
this field!

Thanx a lot for help!
Steve van Dongen [MSFT] - 01 Sep 2004 03:27 GMT
>Can somebody, please, explain me the way of workin this method!
>
[quoted text clipped - 17 lines]
>
>So what is the point?? I can't catch it!

selectSingleNode searches for the first node that matches the XPath
you pass it.  It returns a reference to the node or null if there is
no node matches the XPath.

selectSingleNode method
http://msdn.microsoft.com/library/en-us/xmlsdk/html/xmmthselectSingleNode.asp

XPath
http://msdn.microsoft.com/library/en-us/xmlsdk/html/conXPath.asp

>And now my problem:
>I have Repeating Table, and want to extract the same values from text-field,
>for example, "task" (it repeats several times)
>So how should I achieve it? To get array, or something, with the values from
>this field!

It would look something like this in JScript.  Other languages would
look much the same.

var tasks = new Array();

// Get all the task nodes
var nodes = XDocument.DOM.selectNodes("//my:task");
if (nodes != null)
{
 var node = null;
 var value;

 // Don't really need to reset but might as well ensure we're
 // at the beginning
 nodes.reset();

 // Get the first node
 node = nodes.nextNode();

 // Loop until there are no more nodes
 while (node != null)
 {
   value = node.text;

   /* do something, i.e. add to an array */
   tasks.push(value);

   // Move to next node
   node = nodes.nextNode();
 }
}

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
Juli V. - 01 Sep 2004 07:04 GMT
Great thanx, Steve!
Your code works great! (minimum modification needed)

I understood this method at last!

>>Can somebody, please, explain me the way of workin this method!
>>
[quoted text clipped - 75 lines]
> rights.
> Sample code subject to http://www.microsoft.com/info/cpyright.htm
 
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.