MSXML2.DOMDocument.xml give me malformed xml

970 Views Asked by At

We have an old legacy system that where a component is writter in VB6. One method returns a string that is xml data. The xml data is created with msxml3.dll MSXML2.DOMDocument and returns the data of the document with the property xml: http://msdn.microsoft.com/en-us/library/ms755989(v=VS.85).aspx

However, some data of the xmldocument is from the database and one field is a hashed password string. The code that set the data for the element:

            Set cellNode = rowNode.appendChild(xml.createElement("COL"))
            If IsNull(rs(oField.name).Value) Then
                cellNode.Text = ""
            Else
                cellNode.Text = rs(oField.name).Value
            End If

This gives me malformed/non-wellformed xml:

<ROWS><ROW><COL>r<í</COL></ROW></ROWS>

Is there a workaround for this?

1

There are 1 best solutions below

0
On

You should escape unicode characters. Or put them in a CDATA tag (which is not such a nice solution though) Btw < > and & should be escaped as well.