I am clueless...
Here is my code:
Private Sub genCodeDynamic(ByVal nIn As XmlNode, ByRef nOut As XmlNode, ByVal docOut As XmlDocument, _
ByVal stopAtNode As XmlNode, ByVal dr As DataRow)
Dim d1 As String = docOut.InnerXml 'debug
Try
Dim t As XmlNode 'text nodes
If Not (nIn Is Nothing) AndAlso nIn.HasChildNodes Then
Dim xc As XmlNodeList = nIn.SelectNodes("*")
Dim x As XmlNode
For Each x In xc
nOut = nOut.AppendChild(docOut.CreateElement(x.Name))
t = x.SelectSingleNode("text()")
If Not (t Is Nothing) Then
If Len(t.Value) > 3 And Microsoft.VisualBasic.Left(t.Value, 3) = "DB:" Then
'Dim dtest As String = dr("docid")
Dim drs As String = Database.safedbstr(dr, Microsoft.VisualBasic.Right(t.Value, Len(t.Value) - 3))
nOut.AppendChild(docOut.CreateTextNode(Database.sa fedbstr(dr, Microsoft.VisualBasic.Right(t.Value, Len(t.Value) - 3))))
Else
nOut.AppendChild(docOut.CreateTextNode(t.Value))
End If
End If
Dim ac As XmlAttributeCollection = x.Attributes
Dim aIn As XmlAttribute
Dim aOut As XmlAttribute
For Each aIn In ac
aOut = docOut.CreateAttribute(aIn.Name)
If Len(aIn.Value) > 3 And Microsoft.VisualBasic.Left(aIn.Value, 3) = "DB:" Then
aOut.Value = Database.safedbstr(dr, Microsoft.VisualBasic.Right(aIn.Value, Len(aIn.Value) - 3))
Else
aOut.Value = aIn.Value
End If
'ret = ret & "a.Value = """ & a.Value & """" & vbCrLf
nOut.Attributes.SetNamedItem(aOut)
Next
'Now get all the child nodes of x
If x.HasChildNodes AndAlso Not (x Is stopAtNode) Then
'ret = genCode(x, ret, stopAtNode)
genCodeDynamic(x, nOut, docOut, stopAtNode, dr)
End If
nOut = nOut.ParentNode
Next
End If
Catch ex As Exception
handleException(ex)
End Try
End Sub