473,396 Members | 1,775 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,396 software developers and data experts.

Create XML file - According to the Value, add elements under corresponding range

115 100+
i'm using VB.NET.

i'm using this codes to create this XML.
<Employee>
<EmpItem CV="120" PL1="2" PL2="3" /EmpItem>
<EmpItem Cv="2" PL1="6" PL2="4" /EmpItem>
<EmpIten Cv="234" PL1="4" PL"4" /EmpItem>
<DataName>
</Employee>
Expand|Select|Wrap|Line Numbers
  1. TextBox1.Text = "C:\Program\Emp.mdb"
  2. If File.Exists(TextBox1.Text) Then
  3.             Dim strSQL As String = "Select ItemID,pl11,pl12 from MG10 where ItemID <> 0"
  4.             Dim myConnection As New OleDbConnection(strConn)
  5.             myConnection.Open()
  6.             Dim myCommand As OleDbCommand = New OleDbCommand(strSQL, myConnection)
  7.             Dim myReader As OleDbDataReader = myCommand.ExecuteReader
  8.  
  9.             Dim myXWriter As XmlTextWriter
  10.             Dim myWriter As StreamWriter
  11.             Dim myStream As MemoryStream
  12.             myStream = New MemoryStream
  13.  
  14.             myXWriter = New XmlTextWriter(myStream, Encoding.UTF8)
  15.             myXWriter.Formatting = Formatting.Indented
  16.             myXWriter.Indentation = 2
  17.  
  18.             myXWriter.WriteStartDocument()
  19.             myXWriter.WriteStartElement("Employee")
  20.  
  21.            While myReader.Read
  22.                 myXWriter.WriteStartElement("Item")
  23.                 myXWriter.WriteAttributeString("CV", myReader(0))
  24.                 myXWriter.WriteAttributeString("PL1", myReader(1))
  25.                myXWriter.WriteAttributeString("PL2", myReader(2))
  26.                 myXWriter.WriteEndElement()
  27.             End While
  28.  
  29.             myXWriter.WriteFullEndElement()
  30.             myXWriter.WriteFullEndElement()
  31.             myXWriter.WriteEndDocument()
  32.             myXWriter.Flush()
  33.  
  34.            myStream.Seek(0, SeekOrigin.Begin)
  35.  
  36.             Dim strConfig2 As String = New StreamReader(myStream).ReadToEnd()
  37.             myWriter = File.CreateText("C:\Example.xml")
  38.             myWriter.WriteLine(strConfig2)
  39.             myWriter.Close()
  40.         End If
  41.  
anyway is there to create an XML like this...
<Employee>
<EmpRange min="0" max="99">
<EmpItem Cv="2" PL1="6" PL2="4">
</EmpRange>
<EmpRange min="100" max="199">
<EmpItem CV="120" PL1="2" PL2="3">
</EmpRange>
<EmpRange min="200" max="299">
<EmpIten Cv="234" PL1="4" PL"4">
<EmpRange>
<DataName>
</Employee>
according to the CV values can i add the EmpItems in corresponding Range. and the CV values will be random numbers. so if CV value is 34 then it should be under <EmpRange min="0" max="99">. likewise can we create an XML file to add EmpItems according to the range the CV value.

if you have any idea how to create this please help me... if you can provide any help then it will be a great help for me....

thanks in advanace.
Oct 3 '07 #1
0 1067

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

Similar topics

19
by: Peter A. Schott | last post by:
I've got a file that seems to come across more like a dictionary from what I can tell. Something like the following format: ###,1,val_1,2,val_2,3,val_3,5,val_5,10,val_10...
7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
9
by: Arnold | last post by:
I need to read a binary file and store it into a buffer in memory (system has large amount of RAM, 2GB+) then pass it to a function. The function accepts input as 32 bit unsigned longs (DWORD). I...
8
by: Darius Fatakia | last post by:
Hello, I have a file that I have opened for reading and this file contains lines with several different types of constraint information. For example, here are a few lines: length(0) = 10...
4
by: L. | last post by:
Hello, I need to generate random Matrices (say of size 5*5), each with an average of X (say X=0.5), but with different values’ range. One matrix should have values in the range of 0-1, while...
10
by: Charles Law | last post by:
In a VB.NET app, I can write Dim s As String = 3.ToString This is because 3 is of type Int32, which is a structure, which has a method ToString. I would also like to be able to write Dim...
8
by: Shalaka Joshi | last post by:
Hi, I have binary file say, "test.bin". I write "FF" in the file and expect my code to read 255 for me. char * lbuf; int lreadBytes ; long lData; FILE *pFile = fopen ("c:\\testbin","rb");
4
by: Abdhul Saleem | last post by:
Hi, I am recieving error ActiveX component can't create object in the following line in the asp page. set ExcelApp = CreateObject("Excel.Application") Previously this code was working fine....
1
by: remya1000 | last post by:
i'm using VB.NET. i'm using this codes to create this XML. <Employee> <EmpItem CV="120" PL1="2" PL2="3" /EmpItem> <EmpItem Cv="2" PL1="6" PL2="4" /EmpItem> <EmpIten Cv="234" PL1="4" PL"4"...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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,...

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.