<?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: Node Count</title><link>https://www.infopathdev.com:443/forums/thread/31190.aspx</link><pubDate>Tue, 05 Aug 2008 08:42:19 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:31190</guid><dc:creator>ben.oates</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/31190.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=31190</wfw:commentRss><description>&lt;p&gt;Ah! Thank you so much! This is actually where I started but the example I had found didn&amp;#39;t have Set at the start of the line. That makes all the difference in the world!&lt;/p&gt;
&lt;p&gt;I am so new to programming Infopath. Thank you for your help. I think I can work the rest of this out from that link.&lt;/p&gt;</description></item><item><title>Re: Node Count</title><link>https://www.infopathdev.com:443/forums/thread/31186.aspx</link><pubDate>Mon, 04 Aug 2008 23:31:00 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:31186</guid><dc:creator>Hilary Stoupa</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/31186.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=31186</wfw:commentRss><description>&lt;p&gt;Hi --&lt;/p&gt;
&lt;p&gt;VBScript uses the 2003 object model, so you won&amp;#39;t be able to use CreateNavigator with it -- that is for IP 2007 managed code (C# or VB.NET).&lt;/p&gt;
&lt;p&gt;So, if I am reading this right, you need to select some nodes in your form and get a count, do one thing if the count is zero and other if it isn&amp;#39;t... does that sum it up?&lt;/p&gt;
&lt;p&gt;This snipped of VBScript will get a repeating group and pop up a message box telling you how many nodes are in it:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Dim objNodes &lt;br /&gt;&lt;br /&gt;Set objNodes = XDocument.DOM.selectNodes(&amp;quot;/my:myFields/my:Hardware&amp;quot;) &lt;br /&gt;&lt;br /&gt;MsgBox objNodes.length&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;And &lt;a href="http://msdn.microsoft.com/en-us/library/ms754523(VS.85).aspx"&gt;here&lt;/a&gt; is some information from MSDN on the selectNodes method -- which I think is more along the lines of what you need. Hopefully this will get you started on the right path, but let me know if you need more help, okay?&lt;/p&gt;</description></item><item><title>Node Count</title><link>https://www.infopathdev.com:443/forums/thread/31176.aspx</link><pubDate>Mon, 04 Aug 2008 14:08:49 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:31176</guid><dc:creator>ben.oates</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/31176.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=31176</wfw:commentRss><description>&lt;p&gt;Afternoon,&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve been looking around for code that can do this for a few days and all the samples I find use an XDocument.View node select method&amp;nbsp;as part of the code. I don&amp;#39;t actually have all of&amp;nbsp;the nodes that I want to look at in the views that I am calling the function from, so (as far as I understand it - which isn&amp;#39;t very far) that is why this code does not work for me.&lt;/p&gt;
&lt;p&gt;This is VBScript. I have tried a number of different methods but can&amp;#39;t get one to work. My first attempt involved view but I think I got the XPath wrong and as discussed earlier don&amp;#39;t think I can use View anyway. I also can&amp;#39;t get XDocument.DOM.CreateNavigator to work as I found in other examples.&lt;/p&gt;
&lt;p&gt;My data source is structured as follows:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;myFields&lt;/div&gt;&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;Hardware (Repeating)&lt;/div&gt;&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;HWID&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;li&gt;
&lt;div&gt;Software (Repeating)&lt;/div&gt;&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;SWID&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;li&gt;
&lt;div&gt;Order (Repeating)&lt;/div&gt;&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;HWID (Repeating)&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;SWID (Repeating)&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/ul&gt;&lt;/ul&gt;
&lt;p&gt;There are many&amp;nbsp;other fields but these are the important ones at the moment. Each order is populated with hardware/software that was filled in in the other two lists. If the number of items in Hardware or Software is zero I want to remove all items in HWID or SWID lists respectively so as to avoid confusion with less observant users.&lt;/p&gt;
&lt;p&gt;Does anyone have any suggestions on how I might go about this? 2 examples of my many attempts are below and fail miserably.&lt;/p&gt;
&lt;p&gt;I have tried:&lt;/p&gt;
&lt;p&gt;Dim objNode&lt;br /&gt;&amp;nbsp;Dim objNodes&lt;br /&gt;&amp;nbsp;Dim ordNodes&lt;br /&gt;&amp;nbsp;Dim ordObjNodes&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;objNode = XDocument.DOM.selectSingleNode (&amp;quot;//my:myFields/my:Hardware&amp;quot;)&lt;br /&gt;&amp;nbsp;XDocument.View.SelectNodes objXMLNode&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;objNodes = XDocument.View.GetSelectedNodes&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;objNode = XDocument.DOM.selectSingleNode (&amp;quot;//my:myFields/my:Order&amp;quot;)&lt;br /&gt;&amp;nbsp;XDocument.View.SelectNodes objXMLNode&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;ordNodes = XDocument.View.GetSelectedNodes&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;objNode = XDocument.DOM.selectSingleNode (&amp;quot;//my:myFields/my:Order/my:HWID&amp;quot;)&lt;br /&gt;&amp;nbsp;XDocument.View.SelectNodes objXMLNode&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;ordObjNodes = XDocument.View.GetSelectedNodes&lt;br /&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;if objNodes.Count &amp;gt; 0 Then&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;#39;If there are hardware items, make sure there is at least one in the orders&lt;br /&gt;&amp;nbsp;Else&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;#39;If there are no hardware items, remove all hardware items from the orders&lt;br /&gt;&amp;nbsp;End If&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;And&lt;/strong&gt;:&lt;/p&gt;&lt;font size="2"&gt;
&lt;p&gt;xpn = XDocument.Dom.CreateNavigator&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;hNode = xpn.selectSingleNode (&amp;quot;//my:myFields/my:Hardware&amp;quot;, NamespaceManager)&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;oNode = xpn.selectSingleNode (&amp;quot;//my:myFields/my:Order&amp;quot;, NamespaceManager)&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;idNode = XDocument.GetNamedNodeProperty (oNode,&amp;quot;my:HWID&amp;quot;,&amp;quot;Unknown&amp;quot;)&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;if&lt;/font&gt;&lt;font size="2"&gt; hNode.Count &amp;gt; 0 &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;Then&lt;/p&gt;&lt;/font&gt;&lt;font size="2"&gt;
&lt;p&gt;&lt;/font&gt;&lt;font color="#008000" size="2"&gt;&amp;#39;If there are hardware items, make sure there is at least one in the orders&lt;/p&gt;&lt;/font&gt;&lt;font size="2"&gt;
&lt;p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;Else&lt;/p&gt;&lt;/font&gt;&lt;font size="2"&gt;
&lt;p&gt;&lt;/font&gt;&lt;font color="#008000" size="2"&gt;&amp;#39;If there are no hardware items, remove all hardware items from the orders&lt;/p&gt;&lt;/font&gt;&lt;font size="2"&gt;
&lt;p&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;End&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;If&lt;/p&gt;&lt;/font&gt;</description></item></channel></rss>