Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: load vs loadxml - one works with attributes the other not

From: redryderridesagain@-------.--- (--- -----)
To: NULL
Date: 12/4/2004 5:27:00 PM
Its maybe a good thing to post all the code. The contents of the file
"Bad RD*.doc" are also below. Parsing a text selection doesnt work.
Parsing the same text in a lieral works as noted below in the program.

File contents:
<project nerd="Phoenix 2 Clinical Update"></project>

Word macro:
Sub XTranslate()
    Dim stub As String
    Dim xmldoc As New MSXML2.DOMDocument
    With Application.FileSearch
        .FileName = "Bad RD*.doc"
        .LookIn = "D:\Documents and Settings\My Documents\Client
Files\Monthly"
        .Execute
        For i = 1 To .FoundFiles.Count
            MsgBox .FoundFiles(i)
            ' Wait until whole document is loaded before parsing it
            xmldoc.async = False
            Documents.Open FileName:=.FoundFiles(i),
ConfirmConversions _
                :=False, ReadOnly:=True, AddToRecentFiles:=False,
PasswordDocument:="", _
                PasswordTemplate:="", Revert:=False,
WritePasswordDocument:="", _
                WritePasswordTemplate:="", Format:=wdOpenFormatAuto
            Selection.WholeStory
            'stub = "<top><?xml version=""1.0"">
encoding=""ISO-8859-1""?>" & Selection.Text & "</top>"
            'stub = "<top>" & Selection.Text & "</top>"
            'stub = Selection.Text 'This doesnt work
            stub = "<project nerd=""Phoenix 2 Clinical
Update""></project>" ' This works
            MsgBox (stub)
            ' Process file
            If xmldoc.loadXML(stub) Then
            'If xmldoc.Load(.FoundFiles(i)) Then
                Call PrintDOM(xmldoc)
                Call xreportWord(xmldoc)
            Else
                MsgBox ("Nyet! " & xmldoc.parseError.Line & " " &
xmldoc.parseError.srcText & _
                " " & xmldoc.parseError.reason)
            End If
            Next i
    End With
End Sub


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent