<?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: XPATH to repeating sect. entry via attr value?</title><link>https://www.infopathdev.com:443/forums/thread/14126.aspx</link><pubDate>Fri, 16 Dec 2005 20:35:28 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:14126</guid><dc:creator>jeankap</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/14126.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=14126</wfw:commentRss><description>Oh yeah!  That helps considerably.  I did have some kind of XPATH /DOM thing within the For each at one point, but that wasn't working for me either...  &lt;br /&gt;&lt;br /&gt;Now I just gotta figure out how to conditionally get rid of the sections (which should be much easier that I can actually get to those context values...)&lt;br /&gt;&lt;br /&gt;Thanks!&lt;br /&gt;&lt;br /&gt;&lt;blockquote id="quote"&gt;&lt;font size="1" face="Verdana, Arial, Helvetica" id="quote"&gt;quote:&lt;hr height="1" noshade id="quote"&gt;&lt;i&gt;Originally posted by MFaus&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;Change this:&lt;br /&gt;&lt;br /&gt;Dim contextNode As IXMLDOMAttribute = domDoc.selectSingleNode("/my:XPF/my:DesignSurvey/my:Divisions/my:Opener/my:OpenerEntry/@my:Context")&lt;br /&gt;&lt;br /&gt;Dim attrValue As String = contextNode.text&lt;br /&gt;&lt;br /&gt;For Each node In nodeList&lt;br /&gt;thisXDocument.UI.Alert(attrValue)&lt;br /&gt;Next&lt;br /&gt;&lt;br /&gt;To This:&lt;br /&gt;&lt;br /&gt;For Each node In nodeList&lt;br /&gt;thisXDocument.UI.Alert( node.selectSingleNode( "@my:Context" ).text  )&lt;br /&gt;Next node&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Sorry, if this isn't quite the right syntax - I don't do VB.  Anyway, you are pulling the Context from ONE node and then repeating it for however many totaly entries there are. You need to access internal nodes within the loop, not outside and expect it to "magically update".&lt;br /&gt;&lt;br /&gt;Hope this helps!&lt;br /&gt;&lt;br /&gt;---------------&lt;br /&gt;Matt Faus&lt;br /&gt;InfoPath Dev Texas&lt;br /&gt;&lt;br /&gt;&lt;hr height="1" noshade id="quote"&gt;&lt;/font id="quote"&gt;&lt;/blockquote id="quote"&gt;</description></item><item><title>Re: XPATH to repeating sect. entry via attr value?</title><link>https://www.infopathdev.com:443/forums/thread/14125.aspx</link><pubDate>Fri, 16 Dec 2005 20:05:49 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:14125</guid><dc:creator>Matt Faus</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/14125.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=14125</wfw:commentRss><description>Change this:&lt;br /&gt;&lt;br /&gt;Dim contextNode As IXMLDOMAttribute = domDoc.selectSingleNode("/my:XPF/my:DesignSurvey/my:Divisions/my:Opener/my:OpenerEntry/@my:Context")&lt;br /&gt;&lt;br /&gt;Dim attrValue As String = contextNode.text&lt;br /&gt;&lt;br /&gt;For Each node In nodeList&lt;br /&gt;thisXDocument.UI.Alert(attrValue)&lt;br /&gt;Next&lt;br /&gt;&lt;br /&gt;To This:&lt;br /&gt;&lt;br /&gt;For Each node In nodeList&lt;br /&gt;thisXDocument.UI.Alert( node.selectSingleNode( "@my:Context" ).text  )&lt;br /&gt;Next node&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Sorry, if this isn't quite the right syntax - I don't do VB.  Anyway, you are pulling the Context from ONE node and then repeating it for however many totaly entries there are. You need to access internal nodes within the loop, not outside and expect it to "magically update".&lt;br /&gt;&lt;br /&gt;Hope this helps!&lt;br /&gt;&lt;br /&gt;---------------&lt;br /&gt;Matt Faus&lt;br /&gt;InfoPath Dev Texas&lt;br /&gt;</description></item><item><title>XPATH to repeating sect. entry via attr value?</title><link>https://www.infopathdev.com:443/forums/thread/12714.aspx</link><pubDate>Fri, 16 Dec 2005 19:05:43 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:12714</guid><dc:creator>jeankap</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/12714.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=12714</wfw:commentRss><description>I've been fighting with this for a couple of days and cannot see the forest through the trees...&lt;br /&gt;&lt;br /&gt;I have a view that contains a single repeating section.  New sections should be inserted or deleted based on checkbox values on other views.  When a box is checked and a section inserted, I am using VB.net to set a "context" attribute on the repeating section to a value corresponding to the checkbox that spawned the insertion, and displaying the value in the section entry via an expression box control.&lt;br /&gt;&lt;br /&gt;Here's the repeating section data source tree:&lt;br /&gt;&lt;br /&gt;my:Root&lt;br /&gt;... my:DesignSurvey&lt;br /&gt;   ....  my:Divisions&lt;br /&gt;      ..... my:Opener&lt;br /&gt;         ...... my:OpenerEntry (this repeats)&lt;br /&gt;&lt;br /&gt;my:OpenerEntry has a series of boolean attributes (more checkboxes) and one text attribute, my:Context, to keep track of which checkbox from the other view spawned the insertion of whichever specific entry.&lt;br /&gt;&lt;br /&gt;I've got the first part working - that is, the part where you check a box, and the onAfterChange event walks the dom and inserts a new repeating section, and then sets the context attribute:&lt;br /&gt;&lt;br /&gt;        &amp;lt;InfoPathEventHandler(MatchPath:="/my:XPF/my:DesignSurvey/my:Divisions/my:Part/@my:PartOpener", EventType:=InfoPathEventType.OnAfterChange)&amp;gt; _&lt;br /&gt;        Public Sub PartOpener_attr_OnAfterChange(ByVal e As DataDOMEvent)&lt;br /&gt;            ' Write code here to restore the global state.&lt;br /&gt;&lt;br /&gt;            If (e.IsUndoRedo) Then&lt;br /&gt;                ' An undo or redo operation has occurred and the DOM is read-only.&lt;br /&gt;                Return&lt;br /&gt;&lt;br /&gt;            ElseIf (Not (e.Site Is e.Parent)) Then&lt;br /&gt;                Return&lt;br /&gt;&lt;br /&gt;            ElseIf ("Insert" &amp;lt;&amp;gt; e.Operation) Then&lt;br /&gt;                Return&lt;br /&gt;&lt;br /&gt;            End If&lt;br /&gt;&lt;br /&gt;            'A field change has occurred and the DOM is writable. Write code here to respond&lt;br /&gt;            'to the changes.&lt;br /&gt;            Dim domDoc As IXMLDOMDocument = thisXDocument.DOM&lt;br /&gt;&lt;br /&gt;            If e.Source.text = "1" Then&lt;br /&gt;&lt;br /&gt;                Dim oTemplateGrp As IXMLDOMElement = domDoc.selectSingleNode("/my:XPF/my:DesignSurvey/my:Divisions/my:Opener/my:OpenerEntry")&lt;br /&gt;&lt;br /&gt;                Dim oTemplateNode As IXMLDOMElement = oTemplateGrp.cloneNode(True)&lt;br /&gt;&lt;br /&gt;                domDoc.selectSingleNode("/my:XPF/my:DesignSurvey/my:Divisions/my:Opener").appendChild(oTemplateNode)&lt;br /&gt;&lt;br /&gt;                Dim chkExpression As IXMLDOMAttribute = domDoc.selectSingleNode("my:XPF/my:DesignSurvey/my:Divisions/my:Opener/my:OpenerEntry/@my:Context")&lt;br /&gt;&lt;br /&gt;                If chkExpression.value = "" Then&lt;br /&gt;                    Dim parentOpener As IXMLDOMElement = domDoc.selectSingleNode("my:XPF/my:DesignSurvey/my:Divisions/my:Opener")&lt;br /&gt;&lt;br /&gt;                    parentOpener.removeChild(oTemplateGrp)&lt;br /&gt;                End If&lt;br /&gt;&lt;br /&gt;                Dim contextNode As IXMLDOMElement = domDoc.selectSingleNode("/my:XPF/my:DesignSurvey/my:Divisions/my:Opener/my:OpenerEntry")&lt;br /&gt;&lt;br /&gt;                contextNode.setAttribute("my:Context", "Part")&lt;br /&gt;&lt;br /&gt;However, I have not been able to figure out how to navigate back to the correct repeating section if I go back to the view where I originally checked the box to insert the entry and uncheck the box...  I thought I could do this by checking the context attribute value, but found that whatever value assigned to the context attribute from the last checkbox entry appears to have been reassigned to the context attribute in all of the entries despite the persistence of the correct text in the expression box in the view...&lt;br /&gt;&lt;br /&gt;I checked this via the second part of the code shown above:&lt;br /&gt;&lt;br /&gt;            ElseIf e.Source.text = "0" Then&lt;br /&gt;&lt;br /&gt;                thisXDocument.UI.Alert(e.Source.text)&lt;br /&gt;&lt;br /&gt;                Dim nodeList As DOMNodeList = domDoc.selectNodes("/my:XPF/my:DesignSurvey/my:Divisions/my:Opener/my:OpenerEntry")&lt;br /&gt;&lt;br /&gt;                thisXDocument.UI.Alert(nodeList.length)&lt;br /&gt;&lt;br /&gt;                Dim node As IXMLDOMNode&lt;br /&gt;&lt;br /&gt;                Dim contextNode As IXMLDOMAttribute = domDoc.selectSingleNode("/my:XPF/my:DesignSurvey/my:Divisions/my:Opener/my:OpenerEntry/@my:Context")&lt;br /&gt;&lt;br /&gt;                Dim attrValue As String = contextNode.text&lt;br /&gt;&lt;br /&gt;                For Each node In nodeList&lt;br /&gt;                    thisXDocument.UI.Alert(attrValue)&lt;br /&gt;                Next&lt;br /&gt;            End If&lt;br /&gt;            Return&lt;br /&gt;&lt;br /&gt;        End Sub&lt;br /&gt; &lt;br /&gt;So for instance, if I check boxes to insert a new repeating section for Appendix, Part, Chapter, and Box, in that order, I get 4 repeating sections, but when I try to display the values of the context attr in a UI.alert, I get whatever value corresponds to the last checkbox checked (in this case, box) 4 times - which means I cannot actually get back to the entry that was originally spawned by the checkbox to remove the node.&lt;br /&gt;&lt;br /&gt;Any ideas?  Am I crossing my XPath apples and oranges and winding up with grapes?  I'm happy to provide more information if this is not enough to start with.&lt;br /&gt;&lt;br /&gt;Thanks,&lt;br /&gt;Jean K.&lt;br /&gt;&lt;br /&gt;</description></item></channel></rss>