Login
`
Templates, Tools and Utilities
|
||
Add a comment to an Icetips ArticlePlease add your comments to this article.
Please note that you must provide both a name and a valid email address in order
for us to publish your comment. Comments are moderated and are not visible until they have been approved. Spam is never approved!
Back to article list Search Articles Add Comment Printer friendly Direct link XML: MS-XML parser code 2004-04-24 -- Jim Kane Newsgroups: comp.lang.clarion,softvelocity.clarion.language
> Has anyone had succes in using the following VB code in Clarion?
>
'---------------------------------------------------------------------------
> -------------------------------------------
> Dim xmlDoc As MSXML2.DOMDocument
> Dim ErrorState As Long
> Dim ErrorString As String
> Dim ErrorCode As Variant
> Dim Desc As String
>
>
> '**** Load the xmldoc into the XML parser ****
> Set xmlDoc = CreateObject("MSXML2.DOMDocument")
> If Not xmlDoc.loadXML(sXMLDocument) Then
> With xmlDoc.parseError
> Desc = " File Pos = " & .filepos & ", Error Code = " &
> ..ErrorCode & ",Line = " & .Line & ", Line Pos = " & .linepos & ",
> Reason = " & .reason & ", Source = " & .srcText
> Err.Raise 1011, Err.Source, Desc
> Exit Function
> End With
> End If
>
>
'---------------------------------------------------------------------------
> -------------------------------------------
Here is a literal translation with a few more details.
However if you try to use the clarion ole control for xml you are likely to
comit suicide before the project is over.
It would be much smarter to generate the interfaces and do it right. I
wrote the code below a long time ago in c5b
then abandoned it and went early binding.
hence I lived.
Jim Kane
program
map
parse(window, long,string, *string),byte
end
parseerror string(500)
window WINDOW('Caption'),AT(,,260,100),GRAY,DOUBLE
OLE,AT(74,27,100,71),USE(?Ole1)
END
END
code
open(window)
0{prop:hide}=1
accept
case event()
of event:openwindow
?ole1{prop:create}='msxml2.domdocument'
if parse(window, ?ole1, 'something.xml', parseerror) then
message(clip(parseerror),'XML error')
post(event:closewindow)
cycle
else
Message('No error')
post(event:closewindow)
cycle
end
end
end
close(window)
parse Procedure(window pW, long pfeq, string pFilename,
*string pErrorstr)
cParseError cstring(20)
res byte
vbtrue equate(-1)
vbfalse equate(0)
Code
pW $ pFEQ{'ASYNC'}=vbfalse
pW $ pFEQ{'ValidateOnParse'}=vbTrue
pW $ pFEQ{'resolveExternals'}=vbFalse
if pW $ pFEQ{'Load("'&clip(pfilename)&'")'}<>vbTrue then
cParseError=pW $ pFEQ{'ParseError'}
if cParseError[1]='`' then
if pW $ pFEQ{cParseError & '.Errorcode'}<>0 then
pErrorStr='Errorcode=' & pW $ pFEQ{cParseError & '.Errorcode'} &
|
' Reason='& pW $ pFEQ{cParseError & '.Reason'} & |
' Line='& pW $ pFEQ{cparseError & '.line'} & |
' Linepos='&pW $ pFEQ{cparseerror & '.linepos'} &
|
' FilePos='&pW $ pFEQ{cParseError & '.filepos'} &
|
' scrText='& pW $ pFEQ{cParseError & ',srcText'}
end
pW $ pFEQ{prop:release}=cParseError
res=3
else
pErrorStr='Isthe MSxml com object installed?'
res=3
end
end
return res
Today is November 21, 2024, 6:46 am This article has been viewed 35367 times. Google search has resulted in 43 hits on this article since January 25, 2004.
|
|