Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Visual Basic > VB 2005 > Pro Visual Basic 2005
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Pro Visual Basic 2005 For advanced Visual Basic coders working in version 2005. Beginning-level questions will be redirected to other forums, including Beginning VB 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro Visual Basic 2005 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old April 23rd, 2013, 08:46 AM
Registered User
Points: 10, Level: 1
Points: 10, Level: 1 Points: 10, Level: 1 Points: 10, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2012
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to search in XML file?

I made book's catalog for my mum, with books saved in XML file.
I made simple search system, but this only returns me, ie. if I would search in names: "Agatha Christie", the program will return me "Agatha Christie" as many times, as there is book's of her. This is what i tried:
Code:
 ' Load the XML file.
        Dim xml_doc As New Xml.XmlDocument
        xml_doc.Load("BooksCatalog.xml")
        Dim tagName As String
        If rdbLastName.Checked Then
            tagName = "LastName"
        ElseIf rdbFirstName.Checked Then
            tagName = "FirstName"
        ElseIf rdbTitle.Checked Then
            tagName = "Title"
        ElseIf rdbYear.Checked Then
            tagName = "Year"
        End If

        Dim child_nodes As XmlNodeList = _
            xml_doc.GetElementsByTagName(tagName)
        Dim LastName As XmlNodeList = xml_doc.GetElementsByTagName("LastName")
        Dim FirstName As XmlNodeList = xml_doc.GetElementsByTagName("FirstName")
        Dim Title As XmlNodeList = xml_doc.GetElementsByTagName("Title")
        Dim Year As XmlNodeList = xml_doc.GetElementsByTagName("Year")

        Dim txt As String = ""
        For Each child As XmlNode In child_nodes
            If child.InnerText = txtFind.Text Then
                lboFind.Items.Add(child.InnerText)
            End If
        Next child
but I want program to return me something like this:
FirstName LastName - Title (Year)

The XML file looks:
Code:
<?xml version="1.0"?>
<BooksBook xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <ListOfBooks>
    <Book>
      <LastName>LastName1</LastName>
      <FirstName>FirstName1</FirstName>
      <Title>Title1</Title>
      <Year>Year1</Year>
    </Book>
    <Book>
      <LastName>LastName2</LastName>
      <FirstName>FirstName2</FirstName>
      <Title>Title2</Title>
      <Year>Year2</Year>
    </Book>
  </ListOfBooks>
</BooksBook>
Can any1 help me?
('Imports System.Xml' were included)
 


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Search and Replace a text in XML file AyatKh XML 17 May 23rd, 2012 09:05 PM
Parse/Load/Search xml file size near about 1 GB sandeep_akhare XML 4 September 19th, 2006 04:47 AM
Search XMl File Problem :@ sir_hosam XML 1 February 1st, 2006 04:16 AM
Search and display fields in XML file kts_33 XML 5 September 28th, 2004 08:17 AM
Search and display fields in XML file kts_33 Classic ASP XML 1 September 22nd, 2004 05:16 AM



All times are GMT -4. The time now is 12:38 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.