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. Advertisements

  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. Advertisements

  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. Advertisements

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,925
  2. Simon Niederberger
    Replies:
    2
    Views:
    18,697
    Christian Kaufhold
    Jan 7, 2005
  3. Andrew Crowe
    Replies:
    1
    Views:
    5,000
    Andrew Crowe
    Sep 13, 2004
  4. Tjerk Wolterink
    Replies:
    2
    Views:
    1,726
    Dimitre Novatchev
    Aug 24, 2006
  5. curiousity

    HOWTO autopost the selection list upon selection

    curiousity, Nov 21, 2003, in forum: ASP .Net Mobile
    Replies:
    0
    Views:
    425
    curiousity
    Nov 21, 2003
  6. Geagleeye

    how to creating new node inside a xml node

    Geagleeye, Aug 2, 2006, in forum: ASP General
    Replies:
    2
    Views:
    317
    Geagleeye
    Aug 3, 2006
  7. Loebb
    Replies:
    0
    Views:
    354
    Loebb
    Feb 23, 2004
  8. Replies:
    1
    Views:
    365
Loading...