Dean,

Because the first xml doc has  a <subMenu>  parent node for
<menuItems> underneath
The Xpath pointed to the parent node and thus your code works fine.

        For Each nChild In xmlSubMenuNode.ChildNodes
            nChildForNew = xmlSubMenu.ImportNode(nChild, True)
            rootNode.AppendChild(nChildForNew)
        Next

vs

        'nChildForNew = xmlSubMenu.ImportNode(xmlSubMenuNode.FirstChild., True)
        'rootNode.AppendChild(nChildForNew)

But, for learning's sake, I would like to see an alternative method
which would allow me to use ImportNode instead of doing the For each
....  if possible.

The importNode method only takes a  xmlnode as a parameter and not a
xmlnodelist. This prevents me from passing a nodelist of <menuItems>
which could be changed in the code above by using SelectNodes instead
of SelectSingleNode.

----

Glad to see you're expanding the Fiala clan and that the son will have
a younger sister to "fight" with. I wonder if "he/she" will have "hoop
dreams" like dear ole Dad ?
Not planning any visit but you never know...

Dean, keep up the good work and thanks, Paul




On 7/20/05, Dean Fiala <[EMAIL PROTECTED]> wrote:
> Import node pulls in whatever node you tell it to. We were grabbing
> too high up.  Just do this instead and grab the first child of the sub
> menu nodes which what you want....
> 
> nChildForNew = xmlSubMenu.ImportNode(nChild.FirstChild, true)
> 
> and you should be all set.
> 
> The little boy is doing very well and is getting taller by the day and
> talking up a storm. Also has a little sister now, 8 months old, who is
> just starting to bug him because she can crawl and grab his toys.
> When you coming out to lose in basketball again?
> 
> On 7/19/05, Paul N. Chu <[EMAIL PROTECTED]> wrote:
> > Hi Dean,
> >
> > How's your son doing ? He was just a wee wee guy "walking" around the
> > neighborhood last time I was in town.
> >
> > Thanks for the code to do the looping.
> > It works fine !!!
> >
> > I was curious how use the importNode method which seems to be designed
> > for this.
> > When I used the importNode the resulting submenu xml had the
> > unwanted element:  <subMenu> as the top element but I only wanted
> > <menuitem> nodes which I could easily append to the root node <menu>.
> >
> > I changed the original code so I don't have the importNode version handy.
> >
> > I will try and followup on the other groups later.
> >
> > Thanks, Paul
> >
> >
> > On 7/19/05, Charles Carroll <[EMAIL PROTECTED]> wrote:
> > > CrossPost this to:
> > > http://groups.yahoo.com/group/XmlToughQuestionsAspClassicAspNet/
> > > and
> > > http://groups.yahoo.com/group/DotNetXML/
> > > tons of XML experts there may have suggestions to improve that code.
> > >
> > > On 7/18/05, Paul N. Chu <[EMAIL PROTECTED]> wrote:
> > > >  Here's is the basic code I have so far:
> > > >
> > > >  '-- Build Top Full Horizontal Menu at Menu1 server control
> > > >  Dim menuXML As New System.Xml.XmlDocument
> > > >  Dim xmlNode As System.Xml.XmlNode
> > > >  menuXML.Load(Server.MapPath("CoStar.xml"))  ' the Menu file
> > > >  Menu1.DataSource = menuXML
> > > >  Menu1.DataBind()  ' Top Horiz Menu built
> > > >
> > > >  '-- Build SubMenu Menu at Menu2 server control
> > > >  Dim xmlSubMenu As XmlDocument = New XmlDocument
> > > >  Dim xmlDeclaration As XmlDeclaration =
> > > >  xmlDoc.CreateXmlDeclaration("1.0", "utf-8", Nothing)
> > > >  Dim rootNode As XmlElement = xmlDoc.CreateElement("Menu")
> > > >  xmlDoc.InsertBefore(xmlDeclaration, xmlDoc.DocumentElement)
> > > >  xmlDoc.AppendChild(rootNode)
> > > >
> > > >  Dim strMenuItemText As String = "Settlement" '-- Hardcoded here
> > > >  Dim myXPath As String =
> > > >  String.Format("/menu/menuItem[text='{0}']/subMenu",
> > > > strMenuItemText)
> > > >
> > > >  'this should point to subMenu node for Settlement menuitem if the
> > > >  Xpath is right
> > > >  xmlNode = menuXML.SelectSingleNode(myXPath)
> > > >
> > > >  ' ??? How to collect all the childNodes and copy to new document
> > > >  '  xmlNode.childNodes loop ? with appendChild etc ?
> > > >
> > > >  Menu2.DataSource = xmlSubMenu
> > > >  Menu2.DataBind()
> > > >
> > > >
> > > >
> > > >  On 7/18/05, Paul N. Chu <[EMAIL PROTECTED]> wrote:
> > > >  > Given the following xml , I would like to XPATH for the Placement or
> > > >  > Settlement  menuitem and then construct another XML file shown below
> > > >  > from the childnodes of the subMenu node.
> > > >  >
> > > >  > <menu>
> > > >  > <menuItem>
> > > >  >  <text>Placement</text>
> > > >  >  <cssclass>highlighteditem</cssclass>
> > > >  >  <subMenu>
> > > >  >        <menuItem>
> > > >  >        <text>Sub Item 3</text>
> > > >  >        <url>page3.html</url>
> > > >  >        </menuItem>
> > > >  >        <menuItem>
> > > >  >        <text>Sub Item 4</text>
> > > >  >        <url>page4.html</url>
> > > >  >        </menuItem>
> > > >  >  </subMenu>
> > > >  > </menuItem>
> > > >  >
> > > >  > <menuItem>
> > > >  > <text>Settlement</text>
> > > >  > <cssclass>highlighteditem</cssclass>
> > > >  >        <subMenu>
> > > >  >                <menuItem>
> > > >  >                <text>Sub Item 3</text>
> > > >  >                <url>page3.html</url>
> > > >  >                </menuItem>
> > > >  >                <menuItem>
> > > >  >                <text>Sub Item 4</text>
> > > >  >                <url>page4.html</url>
> > > >  >                </menuItem>
> > > >  >        </subMenu>
> > > >  > </menuItem>
> > > >  > </menu>
> > > >  >
> > > >  >
> > > >  > This is the desired submenu xml that I would like to create:
> > > >  >
> > > >  > <menu>
> > > >  >        <menuItem>
> > > >  >        <text>Sub Item 3</text>
> > > >  >        <url>page3.html</url>
> > > >  >        </menuItem>
> > > >  >        <menuItem>
> > > >  >        <text>Sub Item 4</text>
> > > >  >        <url>page4.html</url>
> > > >  >        </menuItem>
> > > >  > </menu>
> > > >  >
> > > >  > Thanks, Paul
> > > >  >
> > > >  > On 7/18/05, getsmartpaul86 <[EMAIL PROTECTED]> wrote:
> > > >  > > Hi Xmlers,
> > > >  > >
> > > >  > > I'm looking for an example that would
> > > >  > > use xpath to search a document for a Node and then
> > > >  > > clone / copy that node and it's children to another xmldocument.
> > > >  > >
> > > >  > > I'm working with skmMenu by Scott Mitchell and have a Horizontal 
> > > > Top
> > > >  > > Menu and would like to search the menu xml nodes to find
> > > >  > > the current Top Level Menu and copy it's children
> > > >  > > and then show those nodes also in a left hand - navigation menu.
> > > >  > >
> > > >  > > Thus if the  top menu has   CatA , CatB, CatC
> > > >  > > then the xpath to CatB
> > > >  > > would find all the childnodes of CatB and then copy them
> > > >  > > to a new XML document.
> > > >  > >
> > > >  > > Thanks for your help, Paul
> > > >  > >
> > > >  > >
> > > >  > >
> > > >  > >
> > > >  > >
> > > >  > >
> > > >  > >
> > > >  > > Yahoo! Groups Links
> > > >  > >
> > > >  > >
> > > >  > >
> > > >  > >
> > > >  > >
> > > >  > >
> > > >  > >
> > > >  >
> > > >
> > > >
> > > >
> > > >  ________________________________
> > > >  YAHOO! GROUPS LINKS
> > > >
> > > >
> > > >  Visit your group "AspNetAnyQuestionIsOk" on the web.
> > > >
> > > >  To unsubscribe from this group, send an email to:
> > > >  [EMAIL PROTECTED]
> > > >
> > > >  Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
> > > >
> > > >  ________________________________
> > > >
> > >
> > >
> > >
> > > Yahoo! Groups Links
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> >
> >
> >
> > Yahoo! Groups Links
> >
> >
> >
> >
> >
> >
> >
> 
> 
> --
> Dean Fiala
> Very Practical Software, Inc
> http://www.vpsw.com
> 
> 
> --
> Dean Fiala
> Very Practical Software, Inc
> http://www.vpsw.com
> 
> 
> 
> Yahoo! Groups Links
> 
> 
> 
> 
> 
> 
>


 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspNetAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to