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.

Write file tool - to get the specific values written to the file

Saranya
Saranya Posts: 3
edited August 2017 in Virtualize

Hi there,

I have a scenario where I need to write the outgoing response (xml ) of a responder to a file. I tried the write file option but it writes the whole xml response to the file. I am just wondering if there is a way where I could get only specific values from the xml to the file? or how could I read only specific values from the xml file?

Thanks in advance

Comments

  • keegan_chan
    keegan_chan Posts: 59 ✭✭

    This is one of the ways to accomplish your goal:

    • Add an Extension Tool to your responder's Incoming Request. Write a script (in the extension language of your choice) to read the XML file and return the content.
    • Add a XML Data Bank to this Extension Tool, thus it would use the return value of the Extension Tool as input. Then, you can set up XPaths to parse the XML and store the values into Data Source columns.
    • Finally, on the responder, use Form XML mode on the response to build the response's XML structure. On each field, select "Parameterized" and the Data Source column name of your choice.
  • [Deleted User]
    [Deleted User] Posts: 0 admin
    edited August 2017

    Hi Saranya,

    EDIT: If you're wanting to write the request XML to a file, follow the below, otherwise use Keegan's suggestion.

    An alternative to the above would be to use chained tools to grab the appropriate values and write them to a file. For example, I recommend using an XML Transformer to grab all of the values you wish to write to a file, and then chain the write file tool to the XML Transformer.

    Doing so will create the file you are looking for with the values that you are expecting.

    One thing to note: The XML Transformer creates new lines as \n, so Windows' default notepad will not recognize new lines (notepad only recognizes \r\n). Instead, use a text editor like notepad++ or sublime to view the output in the correct format. Alternatively, you can also write a short script that will correct this for use in notepad.

    Hope this helps!