p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   General .NET (http://p2p.wrox.com/forumdisplay.php?f=122)
-   -   Create XML file - According to the Value, add elem (http://p2p.wrox.com/showthread.php?t=62538)

remya1000 October 2nd, 2007 11:03 PM

Create XML file - According to the Value, add elem
i'm using VB.NET.

i'm using this codes to create this XML.

<EmpItem CV="120" PL1="2" PL2="3" /EmpItem>
<EmpItem Cv="2" PL1="6" PL2="4" /EmpItem>
<EmpIten Cv="234" PL1="4" PL"4" /EmpItem>

TextBox1.Text = "C:\Program\Emp.mdb"
If File.Exists(TextBox1.Text) Then
            Dim strSQL As String = "Select ItemID,pl11,pl12 from MG10 where ItemID <> 0"
            Dim myConnection As New OleDbConnection(strConn)
            Dim myCommand As OleDbCommand = New OleDbCommand(strSQL, myConnection)
            Dim myReader As OleDbDataReader = myCommand.ExecuteReader

            Dim myXWriter As XmlTextWriter
            Dim myWriter As StreamWriter
            Dim myStream As MemoryStream
            myStream = New MemoryStream

            myXWriter = New XmlTextWriter(myStream, Encoding.UTF8)
            myXWriter.Formatting = Formatting.Indented
            myXWriter.Indentation = 2


           While myReader.Read
                myXWriter.WriteAttributeString("CV", myReader(0))
                myXWriter.WriteAttributeString("PL1", myReader(1))
               myXWriter.WriteAttributeString("PL2", myReader(2))
            End While


           myStream.Seek(0, SeekOrigin.Begin)

            Dim strConfig2 As String = New StreamReader(myStream).ReadToEnd()
            myWriter = File.CreateText("C:\Example.xml")
        End If

anyway is there to create an XML like this...

<EmpRange min="0" max="99">
<EmpItem Cv="2" PL1="6" PL2="4">
<EmpRange min="100" max="199">
<EmpItem CV="120" PL1="2" PL2="3">
<EmpRange min="200" max="299">
<EmpIten Cv="234" PL1="4" PL"4">
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.

All times are GMT -4. The time now is 10:51 PM.

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.