Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Re: load vs loadxml - one works with attributes the other not [Thread Next] Re: load vs loadxml - one works with attributes the other notTo: 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
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
