<?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: How to retrieve the value from a previous column in a repeating table (filled from secondary datasource)</title><link>https://www.infopathdev.com:443/forums/thread/26863.aspx</link><pubDate>Thu, 28 Feb 2008 23:10:50 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:26863</guid><dc:creator>Greg Collins</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/26863.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=26863</wfw:commentRss><description>&lt;p&gt;var nodes=XDocument.GetDOM(&amp;quot;pricing&amp;quot;).selectNodes(&amp;quot;/dfs:myFields/dfs:dataFields/tns:pricingResponse/tns:pricingResult/NewDataSet/Table&amp;quot;);&amp;nbsp;&amp;nbsp;&amp;nbsp; //secondary datasource&lt;/p&gt;
&lt;p&gt;for (var i=0; i &amp;lt; nodes.length; i++)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var curregion=nodes(i).selectSingleNode(&amp;quot;REGION&amp;quot;).text ; //fetch current region&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;There are two ways to do this.&lt;/p&gt;
&lt;p&gt;1. Check to make sure i &amp;gt; 0, and then do:&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var prevregion=nodes(i-1).selectSingleNode(&amp;quot;REGION&amp;quot;).text ; //fetch previous region&lt;/p&gt;
&lt;p&gt;2. Use an XPath:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; var prevregion=nodes(i).selectSingleNode(&amp;quot;preceding-sibling::Table[1]/REGION&amp;quot;).text ; //fetch previous region&lt;/p&gt;
&lt;p&gt;The reason your preceding-sibling axis didn&amp;#39;t work is because you were trying to access a non-existent node. nodes(i) refers to &amp;quot;Table&amp;quot; and not &amp;quot;REGION&amp;#39;. Therefore, the preceding-sibling will also point to &amp;quot;Table&amp;quot;. You need to make sure to put &amp;quot;[1]&amp;quot; so that the XPath knows you only want to go back 1 preceding-sibling... otherwise it might try to go all the way back (i.e. same as &amp;quot;[last()]&amp;quot;).&lt;/p&gt;
&lt;p&gt;Either way you choose, you&amp;#39;ll need to make sure you have a valid node before attempting to access the .text property or you will get an exception.&lt;/p&gt;</description></item><item><title>How to retrieve the value from a previous column in a repeating table (filled from secondary datasource)</title><link>https://www.infopathdev.com:443/forums/thread/26839.aspx</link><pubDate>Thu, 28 Feb 2008 10:46:23 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:26839</guid><dc:creator>knudde</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/26839.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=26839</wfw:commentRss><description>&lt;p&gt;1 secondary repeating tabelset containt information from a webservice&lt;/p&gt;&lt;p&gt;1 primary&amp;nbsp; repeating table that i&amp;#39;m filling up with information from the secondary tableset&lt;/p&gt;&lt;p&gt;******&amp;nbsp;&lt;/p&gt;&lt;p&gt;[ code]&lt;/p&gt;&lt;p&gt;var myclone=XDocument.DOM.selectSingleNode(&amp;quot;/my:myFields/my:R_group/my:RT_directreports&amp;quot;).cloneNode(true);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //clone of primary datatable&lt;br /&gt;&lt;/p&gt;&lt;p&gt;
XDocument.DOM.selectNodes(&amp;quot;/my:myFields/my:R_group/my:RT_directreports&amp;quot;).removeAll();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //make sure there&amp;#39;s nothing in before filling up&lt;br /&gt;
&lt;/p&gt;&lt;p&gt;var nodes=XDocument.GetDOM(&amp;quot;pricing&amp;quot;).selectNodes(&amp;quot;/dfs:myFields/dfs:dataFields/tns:pricingResponse/tns:pricingResult/NewDataSet/Table&amp;quot;);&amp;nbsp;&amp;nbsp;&amp;nbsp; //secondary datasource&lt;/p&gt;&lt;p&gt;for (var i=0; i &amp;lt; nodes.length; i++)&lt;/p&gt;&lt;p&gt;{&lt;/p&gt;&lt;p&gt;

var curregion=nodes(i).selectSingleNode(&amp;quot;REGION&amp;quot;).text ;  //fetch current region&lt;/p&gt;&lt;p style="font-weight:bold;"&gt;--&amp;gt; HERE&amp;lt;--&amp;nbsp; &lt;/p&gt;&lt;p style="font-weight:bold;"&gt;I&amp;#39;ld like to retrieve the value of the previous rowset from the secondary datasource&amp;nbsp; and then do a compare..&lt;/p&gt;&lt;p style="font-weight:bold;"&gt;If it the previous sibling would be different (region change from let&amp;#39;s say &amp;#39;USA&amp;#39; to &amp;#39;EMEA&amp;#39; or &amp;quot;LATAM&amp;#39;&amp;quot;, i&amp;#39;ld first enter a blank tableline - to make it more distinguishable.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;//XDocument.UI.Alert(curregion + prevregion);

&lt;/p&gt;&lt;p&gt;myclone.selectSingleNode(&amp;quot;my:F_Region&amp;quot;).text = nodes(i).selectSingleNode(&amp;quot;REGION&amp;quot;).text;&amp;nbsp;&amp;nbsp;  &amp;nbsp;&amp;nbsp;  // fill primary cloned rowset with datafields from secondary rowset&lt;br /&gt;&lt;/p&gt;&lt;p&gt;myclone.selectSingleNode(&amp;quot;my:F_Country&amp;quot;).text = nodes(i).selectSingleNode(&amp;quot;C&amp;quot;).text;&lt;/p&gt;&lt;p&gt;

myclone.selectSingleNode(&amp;quot;my:F_Lastname&amp;quot;).text = nodes(i).selectSingleNode(&amp;quot;SN&amp;quot;).text; 

&lt;/p&gt;&lt;p&gt;myclone.selectSingleNode(&amp;quot;my:F_Firstname&amp;quot;).text = nodes(i).selectSingleNode(&amp;quot;GIVENNAME&amp;quot;).text;&amp;nbsp; &lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;etc.etc..&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;I looked at preceding-sibling stuff but find a bit complex to get through&lt;/p&gt;&lt;p&gt;??&amp;nbsp; var prevregion=nodes(i).selectSingleNode(&amp;quot;preceding-sibling::REGION&amp;quot;).text ;  //fetch previous region&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;p&gt;tnxs&lt;/p&gt;&lt;p&gt;K&lt;br /&gt;&amp;nbsp;&lt;/p&gt;</description></item></channel></rss>