From: Dennis Rose on
I am using VB5 and have decided to take this route because of problems using
INSTR to parse the XML email(see my post on 6/2/10).

I am trying to use the XML parser example code below but can't get it to work:

Dim objXML As MSXML2.DOMDocument
Dim strXML As String
Dim xmlElem As IXMLDOMElement

Set objXML = New MSXML2.DOMDocument

strXML = txtShowPrintArea ' "txtShowPrintArea" contains the XML formatted
Email

If Not objXML.loadXML(strXML) Then ' #### pgm crashes at this line of code
######
Err.Raise objXML.parseError.errorCode, , objXML.parseError.reason
End If

'**** get first name
Set xmlElem = objXML.selectSingleNode("//name part=""first""")
If Not xmlElem Is Nothing Then
MsgBox xmlElem.Text
End If

I get the following error:
Invalid at the top level of the document.

I checked Google but still can't solve it. What's wrong with my code?????

Help


From: dpb on
Dennis Rose wrote:
> I am using VB5 and have decided to take this route because of problems using
> INSTR to parse the XML email(see my post on 6/2/10).
....
I don't know nuttin' about XML, but as Helmut noted, to embed and "=" in
the file the "=" sign is the "escape" character, just as doubling up the
" character for VB strings.

So, if the problem is simply that of the search you were attempting
before, build your search string as

patrn$ = "<name part=3D""first"">"

and you'll be good to go.

IOW, for the match of an "=" sign you'll need to match the string "=3D".

I don't know what else you'll need that has the same issues, but it's
easy enough once you understand the problem.

Of course, if the XML parser handles this transparently, all the better.

Just thought I'd give the VB workaround now that I understand it...

--
From: Dennis Rose on


"dpb" wrote:

> Dennis Rose wrote:
> > I am using VB5 and have decided to take this route because of problems using
> > INSTR to parse the XML email(see my post on 6/2/10).
> ....
> I don't know nuttin' about XML, but as Helmut noted, to embed and "=" in
> the file the "=" sign is the "escape" character, just as doubling up the
> " character for VB strings.
>
> So, if the problem is simply that of the search you were attempting
> before, build your search string as
>
> patrn$ = "<name part=3D""first"">"
>
> and you'll be good to go.
>
> IOW, for the match of an "=" sign you'll need to match the string "=3D".
>
> I don't know what else you'll need that has the same issues, but it's
> easy enough once you understand the problem.
>
> Of course, if the XML parser handles this transparently, all the better.
>
> Just thought I'd give the VB workaround now that I understand it...
>
> --
> .
>

I'm frustrated. I tried it with that search string and it still doesn't work.
From: dpb on
Dennis Rose wrote:
>
> "dpb" wrote:
>
>> Dennis Rose wrote:
>>> I am using VB5 and have decided to take this route because of problems using
>>> INSTR to parse the XML email(see my post on 6/2/10).
>> ....
>> I don't know nuttin' about XML, but as Helmut noted, to embed and "=" in
>> the file the "=" sign is the "escape" character, just as doubling up the
>> " character for VB strings.
>>
>> So, if the problem is simply that of the search you were attempting
>> before, build your search string as
>>
>> patrn$ = "<name part=3D""first"">"
....

> I'm frustrated. I tried it with that search string and it still
> doesn't work.

Then go back to the previous step and work through what is actually
embedded in the source string. I won't swear I did the above exactly
right; it was typed in at the keyboard.

The key is as before, understand the embedding and match it -- once you
do that it _has_ to work... :) (I think you're relying too much on the
characters as displayed rather than worrying enough about what is
actually the byte pattern in memory).

HTH...

--
From: Geo on
On Thu, 03 Jun 2010 18:42:07 -0500, dpb <none(a)non.net> wrote:


>The key is as before, understand the embedding and match it -- once you
>do that it _has_ to work... :) (I think you're relying too much on the
>characters as displayed rather than worrying enough about what is
>actually the byte pattern in memory).
>

Is it not possible to just open the xml file in Notepad to see what is /really/
there?

--
Geo