XmlTextWriter - write without the "xmlns" attributes - vb.net

Hi all,
I'm using xmlTextWriter to create an XML file. I would like to know how to disable the XMLNS attributes added automatically to my tags?
When I create a new xml, these XMLNS are being added automatically, and giving me trouble later on...

Is there anyway to disable it?

* using vb.net

Thanks in advance
nahumbaAsked:
Who is Participating?
 
sakshi_netConnect With a Mentor Commented:
I have created a sample code in page load

Dim writer As New XmlTextWriter("C:\test.xml", System.Text.Encoding.UTF8)

        'Start Document
        writer.WriteStartDocument()
        writer.WriteStartElement("RootTag")

        ' 'Creating the First Element
        writer.WriteStartElement("EmployeeInfo")
        writer.WriteAttributeString("EmpDept", "IT")
        writer.WriteElementString("EmpCode", "123")
        writer.WriteElementString("EmpName", "Sakshi_net")
        writer.WriteEndElement()

        'Creating the Second Element
        writer.WriteStartElement("ProjectInfo")
        writer.WriteElementString("ProjCode", "PR12")
        writer.WriteElementString("ProjName", "CTT")
        writer.WriteEndElement()

        writer.WriteEndElement()
        writer.WriteEndDocument()
        writer.Close()

this creates following xml file with no xmlns tags..
 <?xml version="1.0" encoding="utf-8" ?>
- <RootTag>
- <EmployeeInfo EmpDept="IT">
  <EmpCode>123</EmpCode>
  <EmpName>Sakshi_net</EmpName>
  </EmployeeInfo>
- <ProjectInfo>
  <ProjCode>PR12</ProjCode>
  <ProjName>CTT</ProjName>
  </ProjectInfo>
  </RootTag>

----------
what exactly you are using with xmltextwriter
0
 
nahumbaAuthor Commented:
Hi sakshi_net, that's exactly what I was looking for! Thanks you so much!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.