From: Dee Earley on
On 02/06/2010 17:31, Dennis Rose wrote:
> I need to use the following string as a "Search String" in an Instr
> instruction:
>
> <name part="first">
>
> The quotes around the word "first" are causing the instruction to fail.
>
> How can I test for this Search String?

Why not use a proper XML parser?

--
Dee Earley (dee.earley(a)icode.co.uk)
i-Catcher Development Team

iCode Systems

(Replies direct to my email address will be ignored.
Please reply to the group.)
From: Dee Earley on
On 02/06/2010 20:30, Dennis Rose wrote:
> Input XML formatted Email:
>
> <customer>
> <contact>
> <name part="first">Lisa</name>
>
>
> My actual Code:
> FirstNameStartID = "<name part="& Chr(34)& "first"& Chr(34)& ">"
> 'FirstNameStartID = "<"& frmLeadServiceToProspect.txtLeadsFirstName& ">"
> StringStart = InStr(1, txtShowPrintArea, FirstNameStartID)
> If StringStart> 0 Then ......
>
> It still doesn't work!!

It works fine here.

?txtShowPrintArea
<customer>
<contact>
<name part="first">Lisa</name>

FirstNameStartID = "<name part=" & Chr(34) & "first" & Chr(34) & ">"
StringStart = InStr(1, txtShowPrintArea, FirstNameStartID)
?stringstart
38

Your input data must be not what you expect.

--
Dee Earley (dee.earley(a)icode.co.uk)
i-Catcher Development Team

iCode Systems

(Replies direct to my email address will be ignored.
Please reply to the group.)
From: Dennis Rose on


"Dee Earley" wrote:

> On 02/06/2010 17:31, Dennis Rose wrote:
> > I need to use the following string as a "Search String" in an Instr
> > instruction:
> >
> > <name part="first">
> >
> > The quotes around the word "first" are causing the instruction to fail.
> >
> > How can I test for this Search String?
>
> Why not use a proper XML parser?
>
> --
> Dee Earley (dee.earley(a)icode.co.uk)
> i-Catcher Development Team
>
> iCode Systems
>
> (Replies direct to my email address will be ignored.
> Please reply to the group.)
> .
>

OK, I give up trying to do it the INSTR way, since I never could get it to
work using all of your good suggestions.

Now I am trying to do it the "NEW" way as you suggest. But now I can' get
it to work using the code below:

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?????

From: dpb on
Dennis Rose wrote:
....

> OK, I give up trying to do it the INSTR way, since I never could get it to
> work using all of your good suggestions.

....

Makes no sense unless the string isn't what you think it is but you've
never provided any information to determine what it really is or isn't
to debug from...

Look at the results of sotoo

For i = 1 to Len(StringToSearch)
Debug.Print Ascw(Mid$(StringToSearch,i,1))
Next i

For i = 1 to Len(StringToMatch)
Debug.Print Ascw(Mid$(StringToMatch,i,1))
Next i

And I'm pretty sure you'll find the issue...

--
From: Dennis Rose on


"dpb" wrote:

> Dennis Rose wrote:
> ....
>
> > OK, I give up trying to do it the INSTR way, since I never could get it to
> > work using all of your good suggestions.
>
> ....
>
> Makes no sense unless the string isn't what you think it is but you've
> never provided any information to determine what it really is or isn't
> to debug from...
>
> Look at the results of sotoo
>
> For i = 1 to Len(StringToSearch)
> Debug.Print Ascw(Mid$(StringToSearch,i,1))
> Next i
>
> For i = 1 to Len(StringToMatch)
> Debug.Print Ascw(Mid$(StringToMatch,i,1))
> Next i
>
> And I'm pretty sure you'll find the issue...
>
> --
> .
>

You hit the nail on the head!!

My "StringToMatch" showed as: <name part="first">
The "StringToSearch" showed as: <name part=3D"first">

even though it displays the same as StringToMatch

What does the "3D" after the equal sign mean or do?
First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5 6 7
Prev: Combinations
Next: 7-bit and News Servers