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

  • jakubiakjakubiak Posts: 360 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_parasoftbenken_parasoft Posts: 522 ✭✭✭

    Jython can access Java libraries such as JAXP

  • wadjikarsushantwadjikarsushant Posts: 6

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

  • jakubiakjakubiak Posts: 360 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

  • laksramylaksramy 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?

  • laksramylaksramy Posts: 4

    Got the answer, had to install jython.

  • Hector_RHector_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_parasoftbenken_parasoft Posts: 522 ✭✭✭
    edited October 19

    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

Sign In or Register to comment.