p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/)
-   Pro Visual Basic 2005 (http://p2p.wrox.com/pro-visual-basic-2005-217/)
-   -   How to search in XML file? (http://p2p.wrox.com/pro-visual-basic-2005/89908-how-search-xml-file.html)

d3struktor April 23rd, 2013 08:46 AM

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:

' Load the XML file.
        Dim xml_doc As New Xml.XmlDocument
        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 = _
        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
            End If
        Next child

but I want program to return me something like this:
FirstName LastName - Title (Year)

The XML file looks:

<?xml version="1.0"?>
<BooksBook xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">

Can any1 help me? [:)]
('Imports System.Xml' were included)

All times are GMT -4. The time now is 11:09 PM.

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