XML node selection error

Discussion in 'ASP General' started by glbdev@yahoo.com, Dec 13, 2006.

  1. Guest

    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?
    , Dec 13, 2006
    #1
    1. Advertising

  2. <> wrote in message
    news:...
    > 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?
    >
    Anthony Jones, Dec 13, 2006
    #2
    1. Advertising

  3. Guest

    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 Jones wrote:
    > <> wrote in message
    > news:...
    > > 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?
    > >
    , Dec 13, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    1,435
  2. Simon Niederberger
    Replies:
    2
    Views:
    16,485
    Christian Kaufhold
    Jan 7, 2005
  3. Tjerk Wolterink
    Replies:
    2
    Views:
    1,418
    Dimitre Novatchev
    Aug 24, 2006
  4. Martin Honnen

    Re: Reading XML Node-by-Node

    Martin Honnen, Nov 12, 2008, in forum: ASP .Net
    Replies:
    0
    Views:
    385
    Martin Honnen
    Nov 12, 2008
  5. Geagleeye

    how to creating new node inside a xml node

    Geagleeye, Aug 2, 2006, in forum: ASP General
    Replies:
    2
    Views:
    197
    Geagleeye
    Aug 3, 2006
Loading...

Share This Page