1

I use QT's QDomDocument. There is a problem when using QDomDocument::setContent(), the compiler complains at this line:

< field regexp = "text".+"text" >

I tried so:

  • < field regexp = "text"".+""text" >
  • < field regexp = "text'"'.+'"'text" >
  • < field regexp = "text\".+\"text" >
Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • Why don't you just use a [raw string literal](https://en.cppreference.com/w/cpp/language/string_literal) (variant 6 on that page)? – Jesper Juhl Jun 02 '20 at 19:44

1 Answers1

2

XML attribute values can be delimited by ', which is useful when the attribute value must contain a ".

So, if the attribute value in intended to be, say, text".+"text, use:

<field regexp='text".+"text'>

Alternatively, &quot; can be used for ".

<field regexp="text&quot;.+&quot;text">

See also:

kjhughes
  • 106,133
  • 27
  • 181
  • 240
  • Or just use a [raw string literal](https://en.cppreference.com/w/cpp/language/string_literal). – Jesper Juhl Jun 02 '20 at 19:45
  • @JesperJuhl: I'd only addressed the XML well-formedness concerns. Thanks for adding the suggestion regarding string formation for the C++ function argument, which indeed has to be satisfied first. – kjhughes Jun 02 '20 at 22:07