Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
generate a xml element with more than one url like this
HTML
<document xmlns="http://www.six-interbank-clearing.com/de/pain.001.001.03.ch.02.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://www.six-interbank-clearing.com/de/pain.001.001.03.ch.02.xsd pain.001.001.03.ch.02.xsd">


Thanks
Michel

What I have tried:

I have tried
VB
oXmlGravar.WriteStartElement("Document")
oXmlGravar.WriteAttributeString("xmlns", "http://www.six-interbank-clearing.com/de/pain.001.001.03.ch.02.xsd")


But it does not accept xmlns as a key
Posted
Updated 13-Oct-20 22:17pm
v2
Comments
Richard MacCutchan 14-Oct-20 3:50am    
What exactly is the error message?

Here is an example taken from: XmlWriter.WriteAttributeString Method (System.Xml) | Microsoft Docs[^]
Imports System.IO
Imports System.Xml

Public Class Sample 

  Public Shared Sub Main() 
 
     Dim writer As XmlWriter = Nothing

     writer = XmlWriter.Create("sampledata.xml")
        
     ' Write the root element.
     writer.WriteStartElement("book")

     ' Write the xmlns:bk="urn:book" namespace declaration.
     writer.WriteAttributeString("xmlns","bk", Nothing,"urn:book")
  
     ' Write the bk:ISBN="1-800-925" attribute.
     writer.WriteAttributeString("ISBN", "urn:book", "1-800-925")

     writer.WriteElementString("price", "19.95")

     ' Write the close tag for the root element.
     writer.WriteEndElement()
             
     ' Write the XML to file and close the writer.
     writer.Flush()
     writer.Close()  

  End Sub
End Class
 
Share this answer
 
Refer a similar discussion here: .net - How to create XML with multiple namespace attributes in C# - Stack Overflow[^]

Quote:
Your best bet (read: minimal amount of hacks) is probably going to be a custom IXmlSerializable implementation; you can get part-way to what you want via combinations of XmlRootAttribute, XmlElementAttribute, etc,
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900