Как разобрать код с условием? У меня есть мыльный ответ, и мне нужно напечатать только component_id, который содержит type = 1
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetTerritoriesHierarhyResponse
xmlns="http://parsec.ru/Parsec3IntergationService">
<GetTerritoriesHierarhyResult>
<Territory xsi:type="TerritoryWithComponent">
<ID>13c80b2d-d9d3-47cd-9c11-f80597b61e74</ID>
<TYPE>0</TYPE>
<NAME>OFFLINE</NAME>
<PARENT_ID>88ef0e32-3b6f-467c-a0ec-0733317f6757</PARENT_ID>
<COMPONENT_ID>13c80b2d-d9d3-47cd-9c11-f80597b61e74</COMPONENT_ID>
<FEATURE_MASK>0</FEATURE_MASK>
</Territory>
K>0</FEATURE_MASK>
</Territory>
<Territory xsi:type="TerritoryWithComponent">
<ID>7d432ebb-6199-44c5-b67b-4671718e6e3c</ID>
<TYPE>1</TYPE>
<NAME>PREO</NAME>
<PARENT_ID>88ef0e32-3b6f-467c-a0ec-0733317f6757</PARENT_ID>
<COMPONENT_ID>7d432ebb-6199-44c5-b67b-4671718e6e3c</COMPONENT_ID>
<FEATURE_MASK>0</FEATURE_MASK>
</Territory>
</GetTerritoriesHierarhyResult>
</GetTerritoriesHierarhyResponse>
</soap:Body>
</soap:Envelope>
У меня есть код
from bs4 import BeautifulSoup
xml = response.content
soup = BeautifulSoup(xml, 'xml')
for i in soup.find_all('Territory'):
print(i.text)
ответ
13c80b2d-d9d3-47cd-9c11-f80597b61e740OFFLINE88ef0e32-3b6f-467c-a0ec-0733317f675713c80b2d-d9d3-47cd-9c11-f80597b61e740
7d432ebb-6199-44c5-b67b-4671718e6e3c0PREO88ef0e32-3b6f-467c-a0ec-0733317f67577d432ebb-6199-44c5-b67b-4671718e6e3c0
Я думаю, мне нужно что-то вроде
for i in soup.find_all('Territory'):
if type = 1 print component_id