I am exporting lotus Notes data into xml using dom parser classes. The export works fine, but there is one field which is rich text field and user attaches some documents in this field, if this attachment has any special charaters then the agent is getting failed. Does anyone has any one handled this earlier. If so, please post the code. Thankyou in advance for your help.
Subject: XML Special characters
Hello.
It would help to know what specific class and method call is failing. And a few of the calls leading up to the failure.
Are you exporting to a stream? variable? other? Are there XSLTransformers that may be incorrectly processing data? Is pipelining involved?
Subject: RE: XML Special characters
William,
Thankyou for your reply. Let me post my code here-
Sub walkTree ( node As NotesDOMNode)
Dim child As NotesDOMNode
Dim attrs As NotesDOMNamedNodeMap
Dim a As NotesDOMAttributeNode
Dim piNode As NotesDOMProcessingInstructionNode
LF = Chr(13)+Chr(10)
If Not node.IsNull Then
Select Case node.NodeType
Case DOMNODETYPE_DOCUMENT_NODE: 'It's the Document node
Set child = node.FirstChild 'Get first node
Dim numChildNodes As Integer
numChildNodes = node.NumberOfChildNodes
'Create an XML declaration for the output
Dim xNode As NotesDOMXMLDeclNode
Set xNode = node.FirstChild
domParser.Output({<?xml version="} + xNode.Version + {" ?>})
'Get the number of children of Document, and call walkTree for the first child
While numChildNodes > 0
Set child = child.NextSibling 'Get next node
numChildNodes = numChildNodes - 1
Call walkTree(child)
Wend
Case DOMNODETYPE_DOCUMENTTYPE_NODE: 'It's a <!DOCTYPE> tag
domParser.Output({Document Type node: } + node.NodeName + LF)
Case DOMNODETYPE_TEXT_NODE: 'It's a plain text node
If node.NodeValue <> Chr(10) Then
'If node.NodeName = "age" Then
'If node.NodeValue=="&" Then
' domParser.Output(ret)
'End If
End If
Case DOMNODETYPE_ELEMENT_NODE: 'Most nodes are Element nodes
If node.NodeName = "databaseinfo" Then
Exit Sub
End If
If node.NodeName = "noteinfo" Then
Exit Sub
End If
If node.NodeName = "updatedby" Then
Exit Sub
End If
domParser.Output({<} + node.NodeName)
Dim numAttributes As Integer, numChildren As Integer
numAttributes = node.attributes.numberofentries
Set attrs = node.Attributes 'Get attributes
Dim i As Integer
For i = 1 To numAttributes 'Loop through attributes
Set a = attrs.GetItem(i)
domParser.Output({ }+a.NodeName + {="} + ReplaceString(a.NodeValue,"&"," and ") + {"})
Next
domParser.Output(">")
numChildren = node.NumberOfChildNodes
Set child = node.FirstChild 'Get child
While numChildren > 0
Call walkTree(child)
Set child = child.NextSibling 'Get next child
numChildren = numChildren - 1
Wend
domParser.Output( {</} + node.nodeName + {>} + LF)
Case DOMNODETYPE_COMMENT_NODE: 'It's a Comment
'domParser.Output({Ignoring node: } + Cstr(node.NodeType) + LF)
Case DOMNODETYPE_PROCESSINGINSTRUCTION_NODE: 'It's a PI node
'domParser.Output({Ignoring node: } + Cstr(node.NodeType) + LF)
Case DOMNODETYPE_CDATASECTION_NODE: 'It's a CDATA section
'domParser.Output({Ignoring node: } + Cstr(node.NodeType) + LF)
Case DOMNODETYPE_ENTITYREFERENCE_NODE: 'It's an entity
'domParser.Output({Ignoring node: } + Cstr(node.NodeType) + LF)
Case Else:
'domParser.Output({Ignoring node: } + Cstr(node.NodeType) + LF)
End Select
End If
End Sub
Subject: RE: XML Special characters
besides the code, we also want to know on what line it fails, with what error message or other symptom, and which characters in the data cause the failure.