Submit and vote on feature ideas.

Welcome to the new Parasoft forums! We hope you will enjoy the site and try out some of the new features, like sharing an idea you may have for one of our products or following a category.

Error in XML Data Bank with strings that contain "&"

Options
diego_c
diego_c Posts: 5

Hi,

I have a REST service that I am testing by querying a database for some name values and asserting these values against the service response. The issue I came across is that some values returned by my query contain the "&" symbol and when it tries to get that stored into an XML Data Bank, the whole test fails with the following error:

Invalid XML input: The entity name must immediately follow the '&' in the entity reference.

Additional Details:
No additional details available

Is there any way to bypass this issue?

Example of test passing:

Query results:
Facebook
Coca Cola
Walmart

Tool successfully stores values into XML Data Bank and asserts against service response.

Example of test failing:

Query results:
Facebook
Ben & Jerrys
Twitter

Tool fails to store values and entire test fails because of the "&" symbol in the second value.

Comments

  • grigorb
    grigorb Posts: 17
    edited July 2017
    Options

    The & is a special character in XML that is why you get the error. in the XML that you get from rest call it should be escaped with correct escape sequence "& amp ;" otherwise it is not well formed XML.
    Or if you get not a XML then use Text Data Bank or JSON Data Bank based on returned message format.

  • diego_c
    diego_c Posts: 5
    edited July 2017
    Options

    Using a Text Data Bank seems to be working now. However, is there any way to view the value(s) being stored in the Text Data Bank? With the XML Data Bank you could click on 'Evaluate XPath' and you would get the value that was stored, but I don't see an option to do that with the Text Data Bank.

    For example, the Text Data Bank interprets my SQL query results as such:

    and I'm setting the Text Data Bank to extract the value with the following Extraction Boundaries:

    So in this case, is the Text Data Bank storing all 3 company names? Or is it storing only one of them? Is so, which one?

    Thank you

  • OmarR
    OmarR Posts: 234 admin
    Options

    Good morning,

    Unfortunately, the text databank will only extract the first instance of the extraction. You would need to create several extractions using the row "index" as a boundary to differentiate between the different company names.

    By the way, did you try enabling the "Encode XML characters" option in your DB tool? This option will encode special characters that are contained in your xml payload such as '&' or '<' to avoid breaking the xml when it is passed into an XML databank. I recommend giving this a try if you haven't already.

  • diego_c
    diego_c Posts: 5
    Options

    That worked!! Thank you

  • satyabrata
    satyabrata Posts: 5
    Options

    Hi All,

    I need the data to stored in xml data bank , so that i can compare with REST response.

    The query is running fine without xml databank and giving the invalid xml error after adding the result as XML databank.

    Please let me know how to fix this issue.

  • benken_parasoft
    benken_parasoft Posts: 1,230 ✭✭✭
    Options

    The query is running fine without xml databank and giving the invalid xml error after adding the result as XML databank.

    Let's discuss in this other thread: i-am-getting-error-invalid-xml-input-character-reference-x1a-is-an-invalid-xml-character-while