XmlTextWriter - write without the "xmlns" attributes -

Posted on 2007-07-21
Last Modified: 2013-11-07
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

Thanks in advance
Question by:nahumba
    LVL 2

    Accepted Solution

    I have created a sample code in page load

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

            'Start Document

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

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


    this creates following xml file with no xmlns tags..
     <?xml version="1.0" encoding="utf-8" ?>
    - <RootTag>
    - <EmployeeInfo EmpDept="IT">
    - <ProjectInfo>

    what exactly you are using with xmltextwriter

    Author Comment

    Hi sakshi_net, that's exactly what I was looking for! Thanks you so much!

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now