How to filter data in an XML file
XML is a platform independent language, so the information formatted in XML can be used in any other platforms (Operating Systems). If we create an XML file in one platform it can be used in other platforms also. The .Net technology is widely supported XML file format. Also the Dataset in ADO.NET uses XML format as its internal storage format.
Here we are going to filter an XML file content and store the result in a newly created XML file. We have an XML file Product.XML , and it has a field Product_Price. We are giving a search criteria like the Product_Price >= 3000 and store the result in a newly created XML file Result.XML.Imports System.Xml Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim xmlFile As XmlReader xmlFile = XmlReader.Create("Product.xml", New XmlReaderSettings()) Dim ds As New DataSet Dim dv As DataView ds.ReadXml(xmlFile) dv = New DataView(ds.Tables(0), "Product_price > = 3000", "Product_Name", DataViewRowState.CurrentRows) dv.ToTable().WriteXml("Result.xml") MsgBox("Done") End Sub End Class
Click here to download the input file product.xml
Related Topics
- How to XML in VB.NET
- How to create an XML file in VB.NET
- How to open and read XML file in VB.NET , XmlReader in VB.Net , XmlTextReader in VB.Net
- How to create an XML file in VB.NET using Dataset
- How to open and read an XML file in VB.NET using Dataset
- How to create an XML file from SQL in VB.NET
- How to search in an XML file
- How to insert data from xml to database
- How to create an Excel file from XML
- How to create an XML file from Excel
- How to xml to DataGridView
- How to create a TreevView from XML
- How to create Crystal Reports from XML
- How to serialization in xml
- How to serialize a .Net Object to XML
- How to de-serialize from an XML file to .Net Object