Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Escaping characters in xpath

  • 27-05-2009 4:08pm
    #1
    Registered Users, Registered Users 2 Posts: 21,081 ✭✭✭✭


    Hi all,

    Anyone know how to do an xpath query for a node that contains a character like "["? Trying to execute a query like /node[2] and it's giving out once it reaches the "[" character.

    Cheers.
    Tagged:


Comments

  • Registered Users, Registered Users 2 Posts: 24 xonet


    Without an example of your XML document and the full XPATH string, it is difficult to see where your problem is.


  • Registered Users, Registered Users 2 Posts: 1,140 ✭✭✭alanmc


    Stark wrote: »
    Hi all,

    Anyone know how to do an xpath query for a node that contains a character like "["? Trying to execute a query like /node[2] and it's giving out once it reaches the "[" character.

    Cheers.

    Because [] is an operator in XPath (much the same way it indexes into an array in Java, it is used to index into a NodeSet in XPath), you are very much discouraged from using either '' in your node names.

    I've just done a small test in XMLSpy and it told me that '[' was an illegal character. It can be used in attribute values or in CDATA, but it has special meaning in XML so should not be used when defining your node names.

    Same goes for the likes of : and .

    Al.


  • Registered Users, Registered Users 2 Posts: 5,618 ✭✭✭Civilian_Target


    [ = [
    ] = ]


  • Registered Users, Registered Users 2 Posts: 5,618 ✭✭✭Civilian_Target


    Goddam, it interpreted the codes as chars :(

    [ = [
    ] = ]


Advertisement