Xml - Select Node
Xml - Select Node
Xml - Select Node
Xml - Select Node
Xml - Select Node
Xml - Select Node Xml - Select Node Xml - Select Node Xml - Select Node Xml - Select Node Xml - Select Node Xml - Select Node Xml - Select Node
Xml - Select Node Xml - Select Node
Xml - Select Node
Go Back  Xtreme Visual Basic Talk > > > Xml - Select Node


Reply
 
Thread Tools Display Modes
  #1  
Old 01-27-2014, 10:23 AM
JeremyBenson11 JeremyBenson11 is offline
Regular
 
Join Date: Dec 2013
Posts: 50
Default Xml - Select Node


hmm, lol.

For as much working xml as I've written and had a bit of help get working I'm surprised I can do what I'm trying to do. Anyone know what I've done wrong here?

For some reason the code isn't selecting the book element and appending class elements to it.

In then end the document will look like this.

<project>
<book>
<title></title>
<name></name>
<path></path>
<--- New elements here.
</book>
</project>

Code:
 Dim document As New XmlDocument
        document.Load(ProjectDataMod.projectPathMod + ProjectDataMod.projectNameMod + ".xml")

        Dim nav As XPath.XPathNavigator = document.CreateNavigator()

        nav = nav.SelectSingleNode("/project/book")

        Dim counter As SByte = 0
        Dim amountOfClasses As SByte = ProjectDataMod.classList.Count

        While counter < amountOfClasses

            nav.AppendChildElement("", "class", "", ProjectDataMod.classList.AsReadOnly(counter))

            counter = counter + 1

        End While
Reply With Quote
  #2  
Old 02-01-2014, 01:23 PM
JeremyBenson11 JeremyBenson11 is offline
Regular
 
Join Date: Dec 2013
Posts: 50
Default

Don't suppose anyone gets this? It's weird. I checked it against other code that I have that does the same thing. It looks the same to me, but something must be off...
Reply With Quote
  #3  
Old 02-02-2014, 04:44 AM
PlausiblyDamp's Avatar
PlausiblyDampXml - Select Node PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

If you step through the code in a debugger does it seem to be identifying the correct node to append to? If so are the variables counter and amountOfClasses appearing to hold the correct values?
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
  #4  
Old 02-06-2014, 01:56 PM
JeremyBenson11 JeremyBenson11 is offline
Regular
 
Join Date: Dec 2013
Posts: 50
Default

Hey,

I checked the variables the other day. They come out in a message box good. I even msgboxed the inner html of the selected node. It gave me everything inside. Three elements: title, path, and chapter. Not sure what's up.

It wouldn't be the function that I used.

Code:
nav.AppendChildElement("", "class", "", ProjectDataMod.classList.AsReadOnly(counter))
Creates a new child element node at the end of the list of child nodes of the current node using the namespace prefix, local name and namespace URI specified with the value specified.

-The same method I used in all sections of code, not sure why it wouldn't work...
Reply With Quote
  #5  
Old 02-09-2014, 12:04 PM
PlausiblyDamp's Avatar
PlausiblyDampXml - Select Node PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

I take it there are no exceptions raised when you execute that code?

What is the value returned by ProjectDataMod.classList.AsReadOnly(counter)? If you replace that function call with a hard-coded value does it work then or are you still getting the same problem?

In the debugger does that call show the value of nav being changed?
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Xml - Select Node
Xml - Select Node
Xml - Select Node Xml - Select Node
Xml - Select Node
Xml - Select Node
Xml - Select Node Xml - Select Node Xml - Select Node Xml - Select Node Xml - Select Node Xml - Select Node Xml - Select Node
Xml - Select Node
Xml - Select Node
 
Xml - Select Node
Xml - Select Node
 
-->