[Python] Parsing question for Python with LXML and Requests (Soap)

Discussão em 'Python' iniciado por Stack, Junho 18, 2025.

  1. Stack

    Stack Membro Participativo

    This is an example response:

    <soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/">
    <soap-env:Header />
    <soap-env:Body>
    <api:plexViewResponse xmlns:api="http://alu.com/plexwebapi/api" Command="ACT-USER" SwitchName="" RequestId="ACTUSER1748031686781471283" SessionId="" CongestionIndicator="false" Status="SUCCESS">
    <SessionId>session_123456</SessionId>
    </api:plexViewResponse>
    </soap-env:Body>
    </soap-env:Envelope>"""


    I've figured out how to return sub-elements like sessionid, but I need to obtain the status code from the PlexViewResponse -> Status="SUCCESS"

    I set the namespace, like this

    # Set Namespace
    nsmap = {'api': 'http://alu.com/plexwebapi/api'}
    # Get Session ID
    SessionID = com_login.findall('.//SessionId', nsmap)[0].text


    Struggling to find the proper way to obtain that status, and if it errors, there would be an Error="" also.

    Continue reading...

Compartilhe esta Página