I have an XElement that I need to create via dynamic xml literals/embedded expressions and I need it to inherit the default namespace. This doesn't appear possible though through everything I've tried. Does anyone know how to make this work?
For example
Imports <xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
Sub CreateXAML()
Dim obj = "Rectangle"
Dim objFill As String = obj & ".Fill"
Dim myXML As XElement = <<%= obj %>><<%= objFill %>>no namespace</></>
Dim myXML2 As XElement = <Path><Path.Fill>inherits namespace</Path.Fill></Path>
MsgBox(myXML.ToString & vbCrLf & myXML2.ToString)
End Sub
The first one, myXML
, is not created with the default ns, but the second one, myXML2
, is.