Community discussion forum

Help with XMLWriter

  • 11 months ago
    Hi, I am trying to use XMLWriter to write the following start element: I get the element name and the namespace correct with this statement: xmlWriter.WriteStartElement("GeneralRequest", "http://www.trax2.info/trax/schemas/v1.0/GeneralRequest"); I then try to get the other attributes to display by using xmlWriter.WriteStartattribute - xmlWriter.WriteString and xmlWriter.WriteEndAttribute() in various permutations. However, I cannot get the namespace prefix nor the xsi prefix to display correctly. It keeps on appending the xsi:xmlns="" attributes or other attributes that I don't want. What is the best way to get the start element and its attributes the way I need it to be?
  • 11 months ago
    Hi, I tried to reproduce your problem, but I couldn't. Dim objStream As New IO.StringWriter() Dim objWriter As New Xml.XmlTextWriter(objStream) objWriter.WriteStartDocument(True) objWriter.WriteStartElement("root", "http://www.trax2.info/trax/schemas/v1.0/GeneralRequest") objWriter.WriteStartAttribute("test") objWriter.WriteEndAttribute() objWriter.WriteStartElement("ele") objWriter.WriteFullEndElement() objWriter.WriteEndDocument() objWriter.Close() MsgBox(objStream.ToString()) I tried this... is your code similar to this?

Post a reply

Enter your message below

Sign in or Join us (it's free).

We'd love to hear what you think! Submit ideas or give us feedback