1

I want to add xml declaration like

?xml version="1.0" encoding="UTF-8" standalone="no"?

this text in my xml. How to do it with vb.net ? any idea?

2
  • Why do you need to add a header? Would it not be easier to create a document, then add nodes to it? In this case, it will already have the header in place. Commented Apr 25, 2014 at 13:26
  • @Neolisk its not adding the header automatically. for my stuff I need to add it. Commented Apr 25, 2014 at 13:43

1 Answer 1

3
Dim xmlDoc As New XmlDocument()
xmlDoc.AppendChild(.CreateXmlDeclaration("1.0", "utf-8", Nothing))

Refer to MSDN for more information: http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.createxmldeclaration.aspx

Sign up to request clarification or add additional context in comments.

4 Comments

Dim xmldecl As XmlDeclaration xmldecl = doc.CreateXmlDeclaration("1.0", Nothing, Nothing) xmldecl.Encoding = "UTF-8" xmldecl.Standalone = "yes" doc.AppendChild(xmldecl)
I tried this. and it worked. but I followed your suggestion. thanks anyway.
<?eclipse-pydev version="1.0"?> now I want to add this header. Any idea??
@istiaq2379 -- I'd suggest following the documentation at the link I sent. Or ask as a separate question. If I've answered this question for you, please accept it as the answer.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.