MSXML: How to get the node's line number?



VBA example:



Dim XMLDoc As MSXML2.DOMDocument60
Dim Node_List As MSXML2.IXMLDOMNodeList
Dim Node As MSXML2.IXMLDOMElement
Dim Validate_ParseError As MSXML2.IXMLDOMParseError2

'
' Initialization, reading XMLDoc etc.
'

Set Node_List = XMLDoc.SelectNodes("//kml:coordinates")
For Each Node In Node_List
Set Validate_ParseError = XMLDoc.validateNode(Node)
If (Validate_ParseError.ErrorCode <> 0) Then
' Process parse errors here
End If
Next


The problem is that .Line and .linepos fields of the Validate_ParseError and Validate_ParseError.allErrors's items remain equal to 0 after calling XMLDoc.Validate or XMLDoc.validateNode. So, it is not easy to locate the node in error.


Moreover, it is unclear what to do when the code validation is performed instead of the schema validation. Example: KML coordinates require code validation since they are specified as "list of strings" in the schema.


How can one get the line number for the given node in MSXML?


Thanks!


No comments:

Post a Comment