<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Code</title><link>https://www.infopathdev.com:443/forums/45.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: Listing the value of all fields in the datasource</title><link>https://www.infopathdev.com:443/forums/thread/14331.aspx</link><pubDate>Sat, 04 Mar 2006 10:52:26 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:14331</guid><dc:creator>rjohnson</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/14331.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=14331</wfw:commentRss><description>Hi Matt,&lt;br /&gt;&lt;br /&gt;Thanks for your solution,&lt;br /&gt;&lt;br /&gt;I didn't know how to use selectNodes to get all the descendants, but I now do, thanks to your example.&lt;br /&gt;&lt;br /&gt;Cheers,&lt;br /&gt;&lt;br /&gt;- Reg.</description></item><item><title>Re: Listing the value of all fields in the datasource</title><link>https://www.infopathdev.com:443/forums/thread/14330.aspx</link><pubDate>Sat, 04 Mar 2006 03:25:05 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:14330</guid><dc:creator>Matt Faus</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/14330.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=14330</wfw:commentRss><description>Hi rjohnson,&lt;br /&gt;&lt;br /&gt;I think you're wasting your time with this getDescendents() function! It's already implemented as an XPath axis. Check out this tutorial:&lt;br /&gt;&lt;br /&lt;a target="_blank" href=http://www.w3schools.com/xpath/xpath_axes.asp&gt;http://www.w3schools.com/xpath/xpath_axes.asp&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Also, run this code snippet to get a feel of what's going on:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;	var nl = XDocument.DOM.selectNodes( "/my:myFields/descendant::*" );&lt;br /&gt;	var str = "";&lt;br /&gt;	&lt;br /&gt;	while( (node = nl.nextNode()) != null )&lt;br /&gt;	{		&lt;br /&gt;		//str += node.xml;	&lt;br /&gt;		//str += node.text;	&lt;br /&gt;		str += node.nodeName;	&lt;br /&gt;		str += "\n------------\n";&lt;br /&gt;	}&lt;br /&gt;		&lt;br /&gt;	//XDocument.DOM.selectSingleNode( "//my:field7" ).text = str;&lt;br /&gt;	XDocument.UI.Alert( str );&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;</description></item><item><title>Re: Listing the value of all fields in the datasource</title><link>https://www.infopathdev.com:443/forums/thread/14329.aspx</link><pubDate>Fri, 03 Mar 2006 14:24:08 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:14329</guid><dc:creator>rjohnson</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/14329.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=14329</wfw:commentRss><description>Hi Shanthi,&lt;br /&gt;&lt;br /&gt;Thanks for your reply.&lt;br /&gt;&lt;br /&gt;I tried the selectNodes idea that was given before by Agni, but as noted I couldn't get it to work.&lt;br /&gt;&lt;br /&gt;When I tried again, I noticed the length of the nodelist is always 1.&lt;br /&gt;I however noticed that it shows the number of a repeating section, but this is not what I wanted.&lt;br /&gt;&lt;br /&gt;After searching the internet, I found an example of how you can get the childNodes of a given element (I can't remember which site it was from now, but believe it was another InfoPath Dev Site). I then added to the code to make it work for me and managed to get all the descendants by running through the nodes in a recursive manner.&lt;br /&gt;(I've attached some code at the bottom of this comment)&lt;br /&gt;&lt;br /&gt;If I am wrong about the selectNodes not being able to select all Nodes in a dataSource, could you please verify that.&lt;br /&gt;&lt;br /&gt;Thanks again for your input.&lt;br /&gt;&lt;br /&gt;Regards,&lt;br /&gt;&lt;br /&gt;- Reg.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Code example:&lt;br /&gt;-----------------------&lt;br /&gt;&lt;br /&gt;function CTRL2_5::OnClick(eventObj)&lt;br /&gt;{&lt;br /&gt;   var theNode = XDocument.DOM.selectSingleNode("/my:myFields");&lt;br /&gt;   getDescendants( theNode );&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;function getDescendants( Node )&lt;br /&gt;{&lt;br /&gt;   var nodeList = Node.childNodes;&lt;br /&gt;   var item;&lt;br /&gt;&lt;br /&gt;   for (var i = 0; i &amp;lt; nodeList.length; i++)&lt;br /&gt;   {&lt;br /&gt;      item = nodeList.item(i);&lt;br /&gt;&lt;br /&gt;      // if the item is an element in the dataSource,&lt;br /&gt;      // and not the elements "text".&lt;br /&gt;      if ( item.nodeType == 1 )&lt;br /&gt;      {&lt;br /&gt;         // Outputs the item's value&lt;br /&gt;         XDocument.UI.Alert( item.text )&lt;br /&gt;&lt;br /&gt;         // find the descendants of the current node&lt;br /&gt;         getDescendants( item );&lt;br /&gt;      }&lt;br /&gt;   }&lt;br /&gt;}</description></item><item><title>Re: Listing the value of all fields in the datasource</title><link>https://www.infopathdev.com:443/forums/thread/14328.aspx</link><pubDate>Fri, 24 Feb 2006 18:12:07 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:14328</guid><dc:creator>Shanthi Reddy</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/14328.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=14328</wfw:commentRss><description>Hello,&lt;br /&gt;  When you do a selectNodes you will get all of the nodes as a nodelist. Then you can have a for each loop that will walk through all of these nodes and get the information that you need.</description></item><item><title>Re: Listing the value of all fields in the datasource</title><link>https://www.infopathdev.com:443/forums/thread/14327.aspx</link><pubDate>Fri, 24 Feb 2006 02:05:17 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:14327</guid><dc:creator>rjohnson</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/14327.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=14327</wfw:commentRss><description>Hi Agni,&lt;br /&gt;&lt;br /&gt;Thanks for your reply, but I am confused with your example code.&lt;br /&gt;&lt;br /&gt;I'll try to clarify my question:&lt;br /&gt;Pretend I have 5 field(elements), under the myFields group. I want to run some code which will find all fields under the myFields group and then display the fields value one at a time.&lt;br /&gt;&lt;br /&gt;From your code, I'm not sure what node is. I would assume that node is a variable, that is the group that I want to start the search from. However, I am not sure how to create such a variable.&lt;br /&gt;I would guess:&lt;br /&gt;&lt;b&gt;var node = XDocument.DOM.selectSingleNode("/my:myFields");&lt;/b&gt;&lt;br /&gt;but that doesn't feel right.&lt;br /&gt;&lt;br /&gt;I am also confused when you said loop through the nodes, as I am confused how to do this as well.&lt;br /&gt;&lt;br /&gt;Any help would be greatly appreciated.&lt;br /&gt;&lt;br /&gt;Thanks&lt;br /&gt;&lt;br /&gt;- Reg.</description></item><item><title>Re: Listing the value of all fields in the datasource</title><link>https://www.infopathdev.com:443/forums/thread/14326.aspx</link><pubDate>Thu, 23 Feb 2006 15:18:48 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:14326</guid><dc:creator>Agni Jonnalagadda</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/14326.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=14326</wfw:commentRss><description>Hi, &lt;br /&gt;Try this XPath you should be able to get all the child nodes with it.&lt;br /&gt;node.selectNodes("descendant::*");&lt;br /&gt;then loop through these nodes and output those values where ever you want.&lt;br /&gt;&lt;br /&gt;Agni&lt;br /&gt;INFOPATHdev India</description></item><item><title>Listing the value of all fields in the datasource</title><link>https://www.infopathdev.com:443/forums/thread/12786.aspx</link><pubDate>Thu, 23 Feb 2006 00:15:27 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:12786</guid><dc:creator>rjohnson</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/12786.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=12786</wfw:commentRss><description>Hi everyone,&lt;br /&gt;&lt;br /&gt;Is it possible to use code to run through all elements in the DataSource and display the output of each field. (ie: via a while loop)&lt;br /&gt;&lt;br /&gt;Also, is this possible to do this for a given folder within the DataSource?</description></item></channel></rss>