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.

How to parse response in jython extension tool?

Any tutorial to parse xml response in jython extension tool? or any library best to use with soatest

Tagged:

Comments

  • jakubiak
    jakubiak Posts: 813 admin

    There is no one recommended library for parsing XML within a Jython Extension Tool in SOAtest. I did a quick search and found that a commonly recommended library is a python library called ElementTree (see https://stackoverflow.com/questions/1912434/how-do-i-parse-xml-in-python). Jython is a Java implementation of Python, and it added support for ElementTree in Jython 2.5 which is the version that ships with SOAtest. See http://www.jython.org/docs/_sources/library/xml.etree.elementtree.txt.

  • benken_parasoft
    benken_parasoft Posts: 1,302 ✭✭✭

    Jython can access Java libraries such as JAXP

  • wadjikarsushant
    wadjikarsushant Posts: 6

    @jakubiak how to include ElemenTree ? do i have to add any library?

  • jakubiak
    jakubiak Posts: 813 admin

    No, you only have to add the correct import at the top of your script, as described in the stackoverflow link I posted:

    import xml.etree.ElementTree

  • laksramy
    laksramy Posts: 4

    I am trying to use ElementTree on Extension Tool using Jython but I am running into this error - ImportError: No module named xml

    My SOATest version is 9.10 and I assumed that ElementTree would be supported. Is there anything else I need to do?

  • laksramy
    laksramy Posts: 4

    Got the answer, had to install jython.

  • Hector_R
    Hector_R Posts: 1

    laksramy,

    How did you install jython and Parasoft picked it up. I follow the steps it listed yet I'm getting the following error the moment I do the following statement:

    from xml.etree import ElementTree as ET

    I get the following error:
    Traceback (most recent call last):, File "", line 6, in , File "C:\devTools\jython2.7.0\Lib\xml\etree\ElementTree.py", line 1280, except SyntaxError as exc:, ^, SyntaxError: mismatched input 'as' expecting COLON,

    Did you get any of this errors?

  • benken_parasoft
    benken_parasoft Posts: 1,302 ✭✭✭
    edited October 2018

    line 6, in , File "C:\devTools\jython2.7.0

    You need to use Jython 2.5.2. For detail and steps, please see Configuring Jython Preferences - Jython Version.

    Please also see my response in this other thread:
    Changing python version in Parasoft SoaTest