QXmlStreamReader choking on "=" in attribute when attribute has "&" instead of "&"



  • Hello,
    Sorry if I'm posting this in the wrong place but I don't know if it's a bug or intended behavior.
    I'm trying to make a screen scraper to pull info from a website using QXmlStreamReader but I'm running into a problem when an HTML tag looks something like this: <script src="example.php?parm1=test&parm2=test" />
    It gives me the error "Expected ';', but got '='." but if I change the & to &amp; then it works fine.

    Is there any workaround for this or would I need to manually change all of the & to &amp before I process the file?

    Thanks


  • Moderators

    Hi,

    That's expected behaviour.

    Your tag is not valid XML; you'll get the same error if you put it through an external XML validator (e.g. http://www.w3schools.com/xml/xml_validator.asp )

    You must encode all strings in XML -- that includes converting all "&" to "&amp ;"


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.