Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Continuing with Combobox

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Euzinho Dassilva
Advanced Cheater
Reputation: 0

Joined: 08 Sep 2007
Posts: 62

PostPosted: Sat Oct 13, 2007 7:16 am    Post subject: Continuing with Combobox Reply with quote

Hi

In this topic I post a problem to read a XML file for my Trainer

Searching a lot (and studying too) I finally solve the problem using XPath.

The Beta tests was a success, but what I really want to do with XML Data no.

This my new code, in a combobox Sub:
Code:
    Private Sub listTowns_SelectedValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles listTowns.SelectedValueChanged
        Dim XmlDocument As XmlDocument = New XmlDocument

        Select Case Me.listTowns.SelectedItem
            Case "Falconreach"
                XmlDocument.Load(My.Computer.FileSystem.CurrentDirectory & "\XML\Shop\Falconreach\NormalShop.xml")
        End Select

        Dim Navigator As XPathNavigator = XmlDocument.CreateNavigator

        Dim Expression As XPathExpression = Navigator.Compile("//item")

        Dim Nodes As XPathNodeIterator = Navigator.Select(Expression)

        Select Case Me.listTowns.SelectedItem
            Case "Falconreach"
                While Nodes.MoveNext

                    'Removing Previous Value (if exists)
                    Me.listNormalShops.Items.Clear()

                    'Nodes.Current.MoveToChild("ID", "")
                    'Me.xmlContent.AppendText("Shop ID: " & Nodes.Current.Value & Environment.NewLine)

                    'Nodes.Current.MoveToParent()

                    Nodes.Current.MoveToChild("name", "")
                    'Error: Only add the last item of XML file
                    Me.listNormalShops.Items.Add(Nodes.Current.Value)
                    'Nodes.Current.MoveToParent()

                    Nodes.Current.MoveToParent()
                End While
        End Select
    End Sub

The XML file (modified) is:

Code:
<?xml version="1.0" encoding="utf-8" ?>
<Shop>

   <item>
      <ID>1</ID>
      <name>Yulgar's Shop</name>
   </item>

   <item>
      <ID>2</ID>
      <name>The Inn Shop</name>
   </item>

   <item>
      <ID>3</ID>
      <name>Cysero Shop</name>
   </item>

</Shop>

Note: I post only some items of XML file

Look the line when a comment says: Error:...

The tutorial that I read to explain XPath, write the result in a TextBox field. And works fine.
But, now I need to list the values (the shop names) in a combobox and Nodes.Current.Value only returns me the last name of <item></item> tags

I tried to use AddRange method but don't works to.

Anyone can help me?

Thanks a lot
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites