|
-
Jul 27th, 2004, 01:00 PM
#1
Thread Starter
New Member
Reading data from an XML document
I have an XML document created and I want to write code to read the document and store all the data (inlcuding everything... all tags, attributes, everything!) into a string. I need to be able to pass this string to a function.
Basically, I would like to see the SAME content within the xml file in a text file ..... (I just need to be able to do this)
How do I go about this?
Any sample code would be greatly appreciated!!!
Thx in advance!
BTW .... I am using a webform in .NET!
Last edited by Islesfan; Jul 27th, 2004 at 01:57 PM.
-
Jul 27th, 2004, 03:34 PM
#2
I wonder how many charact
VB Code:
'C#
String myFile = @"C:\test.xml";
System.IO.FileStream fs =
new System.IO.FileStream(myFile, System.IO.FileMode.Open , System.IO.FileAccess.Read);
Byte[] myxml = new Byte[fs.Length];
fs.Read(myxml, 0, myxml.Length);
System.Text.ASCIIEncoding asci = new System.Text.ASCIIEncoding();
String s = asci.GetString(myxml);
'i'm displaying to screen,
'you can google how to write a string to a file
Console.WriteLine(s);
Console.Read();
'vb
Dim fs As New System.IO.FileStream("C:\test.xml",System.Io.FileMode.Open, System.Io.FileAccess.Read)
Dim myxml(fs.length) As Byte
fs.Read(myxml, 0, myxml.Length)
Dim asci As New System.Text.ASCIIEncoding
Dim s as String = asci.GetString(myxml)
'i'm displaying to screen,
'you can google how to write a string to a file
Console.WriteLine(s)
Console.Read()
Last edited by nemaroller; Jul 27th, 2004 at 03:46 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|