Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 650001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:00:20+00:00 2026-05-13T22:00:20+00:00

I have this code for the settings: Dim settings As XmlWriterSettings = New XmlWriterSettings()

  • 0

I have this code for the settings:

Dim settings As XmlWriterSettings = New XmlWriterSettings()
            settings.Indent = True
            settings.OmitXmlDeclaration = True
            settings.NewLineOnAttributes = True

Then I have this code for the writer:

Dim xml As New XmlTextWriter(Server.MapPath("output.xml"), enc)

Please can you tell me how I make the settings apply to the writer?

Thanks a lot,
Phil.

EDIT: Code sample

Sub writexml_OnClick(ByVal sender As Object, ByVal e As EventArgs)
    Try
        'Vars
        Dim securityid As String = Input_securityid.Text
        Dim enc As Encoding 

        Dim settings As XmlWriterSettings = New XmlWriterSettings()
        settings.Indent = True
        settings.OmitXmlDeclaration = True
        settings.NewLineOnAttributes = True
        settings.Encoding = enc

        'Declare the writer and set file name / settings
        Dim xml As XmlWriter = XmlWriter.Create(Server.MapPath("output.xml"), settings)

        'start document
        xml.WriteStartDocument()
        xml.WriteComment("")

        'start envelope
        xml.WriteStartElement("soap", "Envelope", "http://schemas.xmlsoap.org/soap/envelope/")
        'start body
        xml.WriteStartElement("soap", "Body", Nothing)
        xml.WriteAttributeString("xmlns", "ns1", Nothing, "http://its/foo.wsdl")

        'start biographical capture
        xml.WriteStartElement("ns1:biographicalcaptureElement")

        'start securityid
        xml.WriteStartElement("ns1:securityid")
        xml.WriteValue(securityid)
        'end securityid 
        xml.WriteEndElement()

        'start requestdata 
        xml.WriteStartElement("ns1:requestdata")

        'end requestdata
        xml.WriteEndElement()
        'end biographical capture
        xml.WriteEndElement()

        'end body
        xml.WriteEndElement()
        'end envelope
        xml.WriteEndElement()
        'end document 
        xml.WriteEndDocument()

        'clean up
        xml.Flush()
        xml.Close()

    Catch ex As Exception
        errorlbl.Text = ex.ToString
    Finally
        errorlbl.Text = ("Created file ok")
    End Try


    End Sub

It does work fine if I use;

Dim xml As New XmlTextWriter(Server.MapPath("output.xml"), enc)

the xml is produced but settings are not applied.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T22:00:20+00:00Added an answer on May 13, 2026 at 10:00 pm

    This won’t get you an XmlTextWriter, but to be honest I’ve always used XmlWriter when writing to a file anyway (XmlWriter is the base class of XmlTextWriter.)

    You can use XmlWriter.Create(Server.MapPath("output.xml"), settings) which will give you an XmlWriter instead of an XmlTextWriter. Your encoding will then need to be set in your settings instance (settings.Encoding = enc.)

    EDIT:

    The sample code provided for me produces:

    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body xmlns:ns1="http://its/foo.wsdl" />
    </soap:Envelope>
    

    EDIT 2:

    Your namespace is causing a problem because it’s trying to put the element name as ns1:securityid when it should be the element name is securityid and the namespace ns1. You’ll need to separate these like you’ve done in the WriteAttributeString call, like so:

    instead of: xml.WriteStartElement("ns1:biographicalcaptureElement")
    use: xml.WriteStartElement("biographicalcaptureElement", "ns1")

    With these changes in place I now get:

    <!---->
    <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
      <soap:Body xmlns:ns1="http://its/foo.wsdl">
        <biographicalcaptureElement xmlns="ns1">
          <securityid>TEST123</securityid>
          <requestdata />
        </biographicalcaptureElement>
      </soap:Body>
    </soap:Envelope>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code: Dim Tasks As New List(Of Task) Tasks.Add(Task.Factory.StartNew(Sub() 'Do whatever End
I have this code: int se = (int) settings.GruppoSegreteria; var acc = db.USR_Accounts.Where( p
I have this code : void Main() { System.Timers.Timer t = new System.Timers.Timer (1000);
I have this code <div id=main style=background:#aaaaaa;float:left;height:160px;margin:5px;position:relative;display:block;width:630px;> <div id=1 class=item style=background:#ffaacc;float:left;width:200px;height:150px;margin:5px;position:absolute;left:0px;top:0px;> </div> <div id=2
I have this code for changing the image of a button: - (void)mouseEntered:(NSEvent *)event
I have this code in XAML <Grid x:Name=LayoutRoot Background=Transparent> <Grid.RowDefinitions> <RowDefinition Height=Auto/> <RowDefinition Height=*/>
I have this code: EditText value = ( EditText )findViewById( R.id.editbox ); Integer int_value
I have this code: ie1.link(:text, /Exception:/) It is producing an error message which I
I have this code: def __init__(self, a, b, c, d...): self.a = a self.b
I have this code to sort an array of objects. The data in the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.