Hello everybody !
Happy Diwali and Happy new year

I report my problem as under :

I have a problem to extract data from XML file.My XML file is small ,limited to 5 to 10 lines.
I want to use XML file as a arranged (readable and printable) text file.

Can you suggest me proper tool or method to use XML file in this way ?

Dani AI

Generated

Brief practical guide for turning a small XML file (5–10 lines) into a readable/printable label or receipt. wants values only (no tags) and knows VB6/VB.NET; is correct that a tiny app is the usual solution. The common flow is: load the XML, extract element/attribute text (this drops tags), map fields to a simple template, then either populate UI labels or build a formatted string for printing.

VB.NET (recommended for ease): use LINQ to XML (XDocument/XElement). Element text is available via .Value, which returns the inner text without tags. Example pattern:

' VB.NET (System.Xml.Linq)
Dim doc As XDocument = XDocument.Load("data.xml")
Dim name As String = doc.Root.Element("Customer").Element("Name").Value
Dim total As String = doc.Root.Element("Order").Element("Total").Value

Dim receipt As String = "Name: " & name & Environment.NewLine & "Total: " & total

VB6 option: use MSXML DOM (add the "Microsoft XML" reference). Use XPath with selectSingleNode / selectNodes and read .text to get node contents:

' VB6 (MSXML)
Dim xmldoc As New MSXML2.DOMDocument60
xmldoc.async = False
If xmldoc.Load("data.xml") Then
    Dim n As MSXML2.IXMLDOMNode
    Set n = xmldoc.selectSingleNode("//Customer/Name")
    If Not n Is Nothing Then MsgBox "Name: " & n.text
End If

Key gotchas and tips: handle namespaces explicitly (XNamespace in LINQ or a NamespaceManager for XPath), distinguish attributes vs elements (attributes are read differently), watch encoding/CDATA, and trim whitespace. For a stable XML shape, consider XmlSerializer to deserialize into classes and then format those objects for printing—this is more maintainable than ad‑hoc node access. For one‑off small files, a simple XDocument-based mapper that fills a string template or UI controls is fastest and safest.

Recommended Answers

All 3 Replies

Do you have the skills to put together a small application in any language to take the file and create what you want from it?

Else if it is only 5-10 lines copy and pasting where needed isn't too difficult.

I want fetched data (no tags) something like label or receipt.Can a small application be build to extract data such way ? I learn from googling about Parser,but I have no sufficient knowledge about these programs.I know VB6 and VB.net.

Yeap you can put together a small application to do what you want.

Maybe the following link may help you: http://www.codeproject.com/Articles/4826/XML-File-Parsing-in-VB-NET

I personally have not used VB.Net for 4 or so years so slightly less useful there, I am a C# developer. They are very similar though so should be possible.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.