Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.clipper.visual-objects > #12956 > unrolled thread
| Started by | D.J.W. van Kooten <vankooten@removethis.ic2.com> |
|---|---|
| First post | 2020-04-29 12:25 +0200 |
| Last post | 2020-05-01 00:16 +0200 |
| Articles | 5 — 2 participants |
Back to article view | Back to comp.lang.clipper.visual-objects
XML parser based on MSXML.DOMDocument not working correctly D.J.W. van Kooten <vankooten@removethis.ic2.com> - 2020-04-29 12:25 +0200
Re: XML parser based on MSXML.DOMDocument not working correctly nk <norbert.k@chello.at> - 2020-04-29 18:18 +0200
Re: XML parser based on MSXML.DOMDocument not working correctly D.J.W. van Kooten <vankooten@removethis.ic2.com> - 2020-04-30 00:21 +0200
Re: XML parser based on MSXML.DOMDocument not working correctly nk <norbert.k@chello.at> - 2020-04-30 23:35 +0200
Re: XML parser based on MSXML.DOMDocument not working correctly D.J.W. van Kooten <vankooten@removethis.ic2.com> - 2020-05-01 00:16 +0200
| From | D.J.W. van Kooten <vankooten@removethis.ic2.com> |
|---|---|
| Date | 2020-04-29 12:25 +0200 |
| Subject | XML parser based on MSXML.DOMDocument not working correctly |
| Message-ID | <c7liafdkuvt779k7ra983ov3vvfenl5agr@4ax.com> |
I ussed the below simple XML parser in VO earlier but I discovered an
issue I didn't know (or see?) before. I can pass a node and a string
and if any isn't found it hits the errorblock, which means that just
passing a tag would work because after hitting the error condition it
will just look up the first available tag without an issue.
However, despite during debugging it showed that both a node and tag
were found I noticed that it disregarded the node and simply returned
the 1st tag found despite the node which has been passed should have
returned the second.
(It also is case dependent which appeared to be an issue too).
Does anybody have an idea why it doesn't work (See below)?
Is there a better XMLParser which can be used straight from VO? Note
that it should also take into account an XML reply containing ![CDATA
; this does work fine in this parser.
I can fix it temporarily with AT3 etc as I know what I can expect in
the XML but it's not ideal so any suggestions are welcome.
Dick
FUNCTION XMLParser(cFile AS STRING,cNode AS STRING,cTag AS STRING) AS
STRING
LOCAL oXML AS OBJECT
LOCAL oXMLNodeObj AS OBJECT
LOCAL cResult AS STRING
LOCAL cbOldErrorBlock AS CODEBLOCK
oXML := OLEAutoObject{"MSXML.DOMDocument"} // Instantiate the parser
IF !oXML:fInit
ErrorBox{,"Can't open XMLDOM "}:show()
RETURN ""
ENDIF
oXML:Async:=.f.
oXML:load(cFile)
BEGIN SEQUENCE
cbOldErrorBlock:=ErrorBlock()
ErrorBlock({|X|DummyFunction(X)})
oXMLNodeObj:=oXML:documentElement:selectNodes(cNode)
cResult:=oXML:GetElementsByTagName(cTag):item(0):NodeTypedValue
RECOVER
END
ErrorBlock(cbOldErrorBlock)
[toc] | [next] | [standalone]
| From | nk <norbert.k@chello.at> |
|---|---|
| Date | 2020-04-29 18:18 +0200 |
| Message-ID | <r8c9ci$ani$1@gioia.aioe.org> |
| In reply to | #12956 |
Hello,
have you seen my XML-parser? With it I read out any XML-file and store
the values in an array. You can adjust it accordingly and store the
values directly in the database etc.
You can find an example at
www.voug-bodensee.net/Zip-Download/XML2Array.zip
Kind regards
Norbert
Am 29.04.2020 um 12:25 schrieb D.J.W. van Kooten:
> I ussed the below simple XML parser in VO earlier but I discovered an
> issue I didn't know (or see?) before. I can pass a node and a string
> and if any isn't found it hits the errorblock, which means that just
> passing a tag would work because after hitting the error condition it
> will just look up the first available tag without an issue.
>
> However, despite during debugging it showed that both a node and tag
> were found I noticed that it disregarded the node and simply returned
> the 1st tag found despite the node which has been passed should have
> returned the second.
>
> (It also is case dependent which appeared to be an issue too).
>
> Does anybody have an idea why it doesn't work (See below)?
>
> Is there a better XMLParser which can be used straight from VO? Note
> that it should also take into account an XML reply containing ![CDATA
> ; this does work fine in this parser.
>
> I can fix it temporarily with AT3 etc as I know what I can expect in
> the XML but it's not ideal so any suggestions are welcome.
>
> Dick
>
>
>
> FUNCTION XMLParser(cFile AS STRING,cNode AS STRING,cTag AS STRING) AS
> STRING
> LOCAL oXML AS OBJECT
>
> LOCAL oXMLNodeObj AS OBJECT
> LOCAL cResult AS STRING
> LOCAL cbOldErrorBlock AS CODEBLOCK
>
> oXML := OLEAutoObject{"MSXML.DOMDocument"} // Instantiate the parser
>
> IF !oXML:fInit
> ErrorBox{,"Can't open XMLDOM "}:show()
> RETURN ""
> ENDIF
> oXML:Async:=.f.
>
> oXML:load(cFile)
> BEGIN SEQUENCE
> cbOldErrorBlock:=ErrorBlock()
> ErrorBlock({|X|DummyFunction(X)})
> oXMLNodeObj:=oXML:documentElement:selectNodes(cNode)
> cResult:=oXML:GetElementsByTagName(cTag):item(0):NodeTypedValue
> RECOVER
> END
> ErrorBlock(cbOldErrorBlock)
>
[toc] | [prev] | [next] | [standalone]
| From | D.J.W. van Kooten <vankooten@removethis.ic2.com> |
|---|---|
| Date | 2020-04-30 00:21 +0200 |
| Message-ID | <kiujafhbjkueanshjrosgj1pbhhk256d9m@4ax.com> |
| In reply to | #12958 |
Replying on message of Wed, 29 Apr 2020 18:18:27 +0200 from nk:
Hello Norbert,
>Hello,
>
>have you seen my XML-parser? With it I read out any XML-file and store
>the values in an array. You can adjust it accordingly and store the
>values directly in the database etc.
>You can find an example at
>
I actually hadn't so that sounds promising. Thanks!
I saw it returned the whole tree of nodes, and elements in a DOS box.
One quick question. Could you maybe point me in the right direction if
I want this:
<sender>
<name><![CDATA[Sendername Ltd]]></name>
</sender>
<delivery>
<name><![CDATA[Delivery name GmbH]]></name>
</delivery>
Which method should I call to get element "name" from node delivery
(where the MS method I used simply returned the name of sender.....)
Can I specifically fetch this name value by passing delivery and name
to one of the functions?
Dick
[toc] | [prev] | [next] | [standalone]
| From | nk <norbert.k@chello.at> |
|---|---|
| Date | 2020-04-30 23:35 +0200 |
| Message-ID | <r8fgas$9sn$1@gioia.aioe.org> |
| In reply to | #12960 |
Hello Dick, it's been a long time since I dealt with this parser. I read out the entire xml-file recursively. Look at the array, here should be the two elements listed. So you can evaluate the array. If you send me a test-file I can try that. Best regards Norbert Am 30.04.2020 um 00:21 schrieb D.J.W. van Kooten: > Replying on message of Wed, 29 Apr 2020 18:18:27 +0200 from nk: > > > Hello Norbert, > >> Hello, >> >> have you seen my XML-parser? With it I read out any XML-file and store >> the values in an array. You can adjust it accordingly and store the >> values directly in the database etc. >> You can find an example at >> > I actually hadn't so that sounds promising. Thanks! > > I saw it returned the whole tree of nodes, and elements in a DOS box. > > One quick question. Could you maybe point me in the right direction if > I want this: > > <sender> > <name><![CDATA[Sendername Ltd]]></name> > </sender> > > <delivery> > <name><![CDATA[Delivery name GmbH]]></name> > </delivery> > > > Which method should I call to get element "name" from node delivery > (where the MS method I used simply returned the name of sender.....) > > Can I specifically fetch this name value by passing delivery and name > to one of the functions? > > Dick >
[toc] | [prev] | [next] | [standalone]
| From | D.J.W. van Kooten <vankooten@removethis.ic2.com> |
|---|---|
| Date | 2020-05-01 00:16 +0200 |
| Message-ID | <sejmafht064p3qi0bhimvvljglm9145jct@4ax.com> |
| In reply to | #12965 |
Replying on message of Thu, 30 Apr 2020 23:35:25 +0200 from nk: Hello Norbert, >Hello Dick, >it's been a long time since I dealt with this parser. I read out the >entire xml-file recursively. > >Look at the array, here should be the two elements listed. So you can >evaluate the array. > >If you send me a test-file I can try that. > Thanks for the offer; currently I've delegated this part of the work and I'll pass on your explanation. I will keep you and other readers posted. Dick
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.clipper.visual-objects
csiph-web