473,403 Members | 2,366 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Read XML file from file server

Hi,

I need to read a xml file present in a file server/web server from stand alone application. Is it possible? If so, please give me an example or the method to read.

Thanks in advance
Sindhu
Feb 9 '10 #1
2 1490
madankarmukta
308 256MB
Could you please ellaborate more on this ?

you want to read xml as it is or into some other format ?

Thanks!
Feb 10 '10 #2
sashi
1,754 Expert 1GB
Hi Sindhu,

Yes, it is possible. There are 3 methods known to me, the list goes on as per below;
  1. XmlTextReader
  2. XmlDocument
  3. XPath

Assuming this is the format of your xml file
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <family>
  3.   <name gender="Male">
  4.     <firstname>Tom</firstname>
  5.     <lastname>Smith</lastname>
  6.   </name>
  7.   <name gender="Female">
  8.     <firstname>Dale</firstname>
  9.     <lastname>Smith</lastname>
  10.   </name>
  11. </family>
  12.  
Expand|Select|Wrap|Line Numbers
  1. Imports System.IO
  2. Imports System.Xml
  3.  
  4. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  5.  
  6.   Dim m_xmlr As XmlTextReader
  7.   'Create the XML Reader
  8.  
  9.   m_xmlr = New XmlTextReader("name_of_the_xml_file_to_read.xml")
  10.   'Disable whitespace so that you don't have to read over whitespaces
  11.  
  12.   m_xmlr.WhiteSpaceHandling = WhiteSpaceHandling.NONE
  13.   'read the xml declaration and advance to family tag
  14.  
  15.   m_xmlr.Read()
  16.   'read the family tag
  17.  
  18.   m_xmlr.Read()
  19.   'Load the Loop
  20.  
  21.   While Not m_xmlr.EOF
  22.     'Go to the name tag
  23.  
  24.     m_xmlr.Read()
  25.     'if not start element exit while loop
  26.  
  27.     If Not m_xmlr.IsStartElement() Then
  28.       Exit While
  29.     End If
  30.     'Get the Gender Attribute Value
  31.  
  32.     Dim genderAttribute = m_xmlr.GetAttribute("gender")
  33.     'Read elements firstname and lastname
  34.  
  35.     m_xmlr.Read()
  36.     'Get the firstName Element Value
  37.  
  38.     Dim firstNameValue = m_xmlr.ReadElementString("firstname")
  39.     'Get the lastName Element Value
  40.  
  41.     Dim lastNameValue = m_xmlr.ReadElementString("lastname")
  42.     'Write Result to the Console
  43.  
  44.     Console.WriteLine("Gender: " & genderAttribute _
  45.       & " FirstName: " & firstNameValue & " LastName: " _
  46.       & lastNameValue)
  47.     Console.Write(vbCrLf)
  48.   End While
  49.   'close the reader
  50.  
  51.   m_xmlr.Close()
  52.  
  53. End Sub
  54.  
Feb 14 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: Yang Li Ke | last post by:
Hi guys! I have some datas that I must check everytime a visitor comes to my site What is better to do: 1- Read data from a file or 2- Read data from a mysql db Thank you
1
by: Oyvind Ostlund | last post by:
I am trying to read a file online, and was just testing a bit. This is what I tried. -------------------------------------- import sys, httplib showlines = 6 try: servername, filename =...
2
by: Jim Richards | last post by:
I have been told by a local PC club technician that 98SE cannot read NTFS drives in a network. Is this true? TIA, Jim.
9
by: John Howard | last post by:
How can I read a text file that is on a UNIX server in VB.Net? Please keep it simple. Thanks, John
4
by: klynn | last post by:
Hi: I'm having problems reading a Microsoft Access file from my ASP.Net app on a Windows Server 2003 machine. The error message: The Microsoft database engine cannot open the file, <my_file>. It...
5
by: jannordgreen | last post by:
I use windows 2000 and Visual Studio 2003. I have a vbnet web application on our intranet that needs to read a text file that sits on a different server. The general user does not have access to...
6
by: dinoo | last post by:
Hi, I would appreciate if some one could help me out. I have to read a client side ini file in Aspx page and use that data in server side processing. Can any one help me out here? Please refer...
3
by: =?Utf-8?B?ZGF2aWQ=?= | last post by:
I try to follow Steve's paper to build a database, and store a small text file into SQL Server database and retrieve it later. Only difference between my table and Steve's table is that I use NTEXT...
8
by: Johnny | last post by:
Hi all: I have an ASP.NET form that reads an Excel file and populates a datagrid. If I load the form in IE on the server, and select a local file, the code works fine. However if I load the form...
4
by: Ross | last post by:
Hello, I am trying to Read and Write to a text file on a web server using Microsoft Visual Basic 2005 Express Edition. So far I have managed to complete my testing with a local text file using...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.