Hi All,

I have a function. It creates an XML element with namespace "pre":

Function newElement(ByVal doc  As XmlDocument, _
                             ByVal Name As String, _
                Optional ByVal text As String = Nothing, _
                Optional ByVal pre  As String = Nothing) As XmlElement
 
  Dim xmlEl As XmlElement = doc.CreateElement(pre, Name, "")
  If Not (text IsNothing) Then xmlEl.InnerText = text
  doc.DocumentElement.AppendChild(xmlEl)
  Return xmlEl
EndFunction

Then, I call that function in this way:
newElement(xmlDoc, "FirstName", "Peter", "pre")

I expect the result:
<pre:FirstName>Peter</FirstName>

However, the result has no "pre:", just:
<FirstName>Peter</FirstName>

Why?????

Mike

This article has been dead for over six months. Start a new discussion instead.