XML node selection error

G

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

Anthony Jones

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,"'","&apos;") & "']")


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

glbdev

Anthony,

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

- Gary


Anthony said:
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,"'","&apos;") & "']")


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?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,008
Messages
2,570,269
Members
46,870
Latest member
hemasindhura

Latest Threads

Top