XML node selection error

XML node selection error

am 13.12.2006 14:45:34 von glbdev

I am trying to select a node in an XML file for deletion. I am using
the following code to select the node:

set node = XmlDoc.selectSingleNode("/dataroot/MainNode[Value = '" +
sSearchCriteria + "']")

Unfortunately, the string "sSearchCriteria" can contain apostrophes
which causes this error:

Error Type:
msxml3.dll (0x80004005)
Expected token ']' found 'STRING'. /dataroot/MainNode[Value =
'Steve'-->'s Auto Parts'<--]

I've tried the "Replace" function to add double, triple, etc
apostrophes but nothing works.

The data in the XML file is not being created by me, and is being used
in several different apllications, so I cannot change it.

Any suggestions?

Re: XML node selection error

am 13.12.2006 15:05:47 von Anthony Jones

wrote in message
news:1166017533.939164.154790@j72g2000cwa.googlegroups.com.. .
> I am trying to select a node in an XML file for deletion. I am using
> the following code to select the node:
>
> set node = XmlDoc.selectSingleNode("/dataroot/MainNode[Value = '" +
> sSearchCriteria + "']")

Try :-


set node = XmlDoc.selectSingleNode("/dataroot/MainNode[Value = '" &
Replace(sSearchCriteria,"'","'") & "']")



>
> Unfortunately, the string "sSearchCriteria" can contain apostrophes
> which causes this error:
>
> Error Type:
> msxml3.dll (0x80004005)
> Expected token ']' found 'STRING'. /dataroot/MainNode[Value =
> 'Steve'-->'s Auto Parts'<--]
>
> I've tried the "Replace" function to add double, triple, etc
> apostrophes but nothing works.
>
> The data in the XML file is not being created by me, and is being used
> in several different apllications, so I cannot change it.
>
> Any suggestions?
>

Re: XML node selection error

am 13.12.2006 16:10:07 von glbdev

Anthony,

Thanks for the reply. Unfortunately, it did not work. This is what the
string looks like after the replace: "Steve's Auto Parts". Is
this correct?

- Gary


Anthony Jones wrote:
> wrote in message
> news:1166017533.939164.154790@j72g2000cwa.googlegroups.com.. .
> > I am trying to select a node in an XML file for deletion. I am using
> > the following code to select the node:
> >
> > set node = XmlDoc.selectSingleNode("/dataroot/MainNode[Value = '" +
> > sSearchCriteria + "']")
>
> Try :-
>
>
> set node = XmlDoc.selectSingleNode("/dataroot/MainNode[Value = '" &
> Replace(sSearchCriteria,"'","'") & "']")
>
>
>
> >
> > Unfortunately, the string "sSearchCriteria" can contain apostrophes
> > which causes this error:
> >
> > Error Type:
> > msxml3.dll (0x80004005)
> > Expected token ']' found 'STRING'. /dataroot/MainNode[Value =
> > 'Steve'-->'s Auto Parts'<--]
> >
> > I've tried the "Replace" function to add double, triple, etc
> > apostrophes but nothing works.
> >
> > The data in the XML file is not being created by me, and is being used
> > in several different apllications, so I cannot change it.
> >
> > Any suggestions?
> >