making proper groups of elements & subelemnets in XML

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
uisng vs2005 & sql2000
i am generating a xml file frm sql using below code
<span style="font-size:x-small; color:#0000ff <font size="2" color="#0000ff
Dim
</font>
<span style="font-size:x-small xmlReader <span style="font-size:x-small; color:#0000ff As<span style="font-size:x-small
<span style="font-size:x-small; color:#0000ff New<span style="font-size:x-small XmlTextReader(ds.GetXml(), XmlNodeType.Element,
<span style="font-size:x-small; color:#0000ff Nothing<span style="font-size:x-small )<font size="2

Response.ContentType =
</font>

<span style="font-size:x-small; color:#800000 "text/xml"
<span style="font-size:x-small <font size="2

</font>
<span style="font-size:x-small; color:#0000ff Dim<span style="font-size:x-small xmlWriter
<span style="font-size:x-small; color:#0000ff As<span style="font-size:x-small
<span style="font-size:x-small; color:#0000ff New<span style="font-size:x-small XmlTextWriter(Response.OutputStream, Encoding.UTF8)<font size="2


</font>

<span style="font-size:x-small; color:#008000 Dim xmlWriter As New XmlTextWriter("C:test.xml", Encoding.UTF8)
<span style="font-size:x-small
xmlWriter.Indentation = 14
xmlWriter.WriteStartDocument()
<font size="2

</font>
<span style="font-size:x-small; color:#0000ff Dim<span style="font-size:x-small elementName
<span style="font-size:x-small; color:#0000ff As<span style="font-size:x-small
<span style="font-size:x-small; color:#0000ff String<span style="font-size:x-small =
<span style="font-size:x-small; color:#800000 ""
<span style="font-size:x-small <font size="2

</font>
<span style="font-size:x-small; color:#0000ff While<span style="font-size:x-small xmlReader.Read()<font size="2


</font>

<span style="font-size:x-small; color:#0000ff Select<span style="font-size:x-small
<span style="font-size:x-small; color:#0000ff Case<span style="font-size:x-small xmlReader.NodeType<font size="2


</font>

<span style="font-size:x-small; color:#0000ff Case<span style="font-size:x-small XmlNodeType.Element

xmlWriter.WriteStartElement(xmlReader.Name)
elementName = xmlReader.Name
<font size="2

</font>

<span style="font-size:x-small; color:#0000ff Exit<span style="font-size:x-small
<span style="font-size:x-small; color:#0000ff Select
<span style="font-size:x-small <font size="2

</font>
<span style="font-size:x-small; color:#0000ff Case<span style="font-size:x-small XmlNodeType.Text

xmlWriter.WriteString(xmlReader.Value)
<font size="2

</font>

<span style="font-size:x-small; color:#0000ff Exit<span style="font-size:x-small
<span style="font-size:x-small; color:#0000ff Select
<span style="font-size:x-small <font size="2

</font>
<span style="font-size:x-small; color:#0000ff Case<span style="font-size:x-small XmlNodeType.EndElement<font size="2


</font>

<span style="font-size:x-small; color:#008000 xmlWriter.WriteEndElement()
<span style="font-size:x-small
xmlWriter.WriteEndElement()

<font size="2

</font>
<span style="font-size:x-small; color:#0000ff Exit<span style="font-size:x-small
<span style="font-size:x-small; color:#0000ff Select
<span style="font-size:x-small <font size="2

</font>
<span style="font-size:x-small; color:#0000ff End<span style="font-size:x-small
<span style="font-size:x-small; color:#0000ff Select
<span style="font-size:x-small <font size="2

</font>
<span style="font-size:x-small; color:#0000ff End<span style="font-size:x-small
<span style="font-size:x-small; color:#0000ff While
<span style="font-size:x-small
xmlWriter.Close()

the xml file get created but the nodes elemnets , sub elemts are not grouped properly nor do i get the first root elemnet
i need it as <abc xlmns.....>
how do i get it and how do i make arranges the elemnets in groups
<hr class="sig svk

View the full article
 
Back
Top