Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    eyl
    eyl is offline
    New to the CF scene
    Join Date
    May 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Backslashes in attribute names?

    I have an XML page (created by a program written by someone else) which contains the following (omitting the contents of the description and other attributes):

    <Table_Row description="" enable\disable="0">

    (This XML is basically the conversion of a table, where enable\disable is the name of one of the column headers).

    However, when I try to read it in Matlab using xmlread, I get an error as it considers "enable" to be a seperate attribute and requires it be followed by an equal sign.

    Is there some way to put a backslash in the attribute name (e.g. an escape sequence)?

    Thx

  • #2
    Moderator
    Join Date
    May 2002
    Location
    Hayward, CA
    Posts
    1,460
    Thanks
    1
    Thanked 23 Times in 21 Posts
    I'm not even sure that's well-formed XML.
    "The first step to confirming there is a bug in someone else's work is confirming there are no bugs in your own."
    June 30, 2001
    author, Verbosio prototype XML Editor
    author, JavaScript Developer's Dictionary
    https://alexvincent.us/blog

  • #3
    eyl
    eyl is offline
    New to the CF scene
    Join Date
    May 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    In what way? (other than the backslash)

    Note that I left out most of the code, as it wasn't relevant to the question.

  • #4
    Senior Coder
    Join Date
    Aug 2006
    Posts
    1,226
    Thanks
    10
    Thanked 269 Times in 268 Posts
    From http://www.w3.org/TR/REC-xml/#NT-Name I don't see a backslash allowed in a "name" for an attribute... I think the program generated illegal XML.

    Dave

  • #5
    Moderator
    Join Date
    May 2002
    Location
    Hayward, CA
    Posts
    1,460
    Thanks
    1
    Thanked 23 Times in 21 Posts
    Yeah, and once the XML parser hits any XML well-formedness error, it is required to stop and bail out, not processing the rest of the document.
    "The first step to confirming there is a bug in someone else's work is confirming there are no bugs in your own."
    June 30, 2001
    author, Verbosio prototype XML Editor
    author, JavaScript Developer's Dictionary
    https://alexvincent.us/blog

  • #6
    eyl
    eyl is offline
    New to the CF scene
    Join Date
    May 2012
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by tracknut View Post
    From http://www.w3.org/TR/REC-xml/#NT-Name I don't see a backslash allowed in a "name" for an attribute... I think the program generated illegal XML.

    Dave
    Quote Originally Posted by Alex Vincent View Post
    Yeah, and once the XML parser hits any XML well-formedness error, it is required to stop and bail out, not processing the rest of the document.
    Well, yeah...that's the problem. The question is if there's an alternative - for example, I aw mention somewhere that non-valid characters can be replaced by their Unicode numeric equivalent, but I'm not clear as to how that would look.

  • #7
    Senior Coder
    Join Date
    Aug 2006
    Posts
    1,226
    Thanks
    10
    Thanked 269 Times in 268 Posts
    I'd be quite surprised if there is a workaround for this. "Non-valid" characters in the *value* of an attribute, sure, but in the name of it, probably not.

    Dave


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •