Sziasztok!
Wsman által visszaadtott xml-eket próbálom parsolni.
Ugye ezeket spiletlni kell, '<?xml version="1.0" encoding="UTF-8"?>' mentén splitelem is, majd az itt írt módszerel kiszedném belőle a namespace eket:
http://q2a.inf.mit.bme.hu/2791/wsman-xml-feldolgozas?show=2791#q2791
from io import StringIO
import xml.etree.ElementTree as ET
# instead of ET.fromstring(xml_str)
it = ET.iterparse(StringIO(xml_str))
for _, el in it:
if '}' in el.tag:
el.tag = el.tag.split('}', 1)[1] # strip all namespaces
root = it.root
Ebben a kódrészletben a for ciklus fejlécének sorára az alábbi errort dobja:
xml.etree.ElementTree.ParseError: no element found: line 1, column 38
Az xml amit feldolgozni akarok:
<?xml version="1.0" encoding="UTF-8"?>
<s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing" xmlns:wsen="http://schemas.xmlsoap.org/ws/2004/09/enumeration" xmlns:n1="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/LMI_DiskPartition" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<s:Header>
<wsa:To>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:To>
<wsa:Action>http://schemas.xmlsoap.org/ws/2004/09/enumeration/PullResponse</wsa:Action>
<wsa:RelatesTo>uuid:24029bce-30ae-10ae-8005-202423565000</wsa:RelatesTo>
<wsa:MessageID>uuid:24032ff8-30ae-10ae-8064-202423565000</wsa:MessageID>
</s:Header>
<s:Body>
<wsen:PullResponse>
<wsen:Items>
<n1:LMI_DiskPartition>
<n1:Access xsi:nil="true"/>
<n1:Allocatable xsi:nil="true"/>
<n1:Availability xsi:nil="true"/>
<n1:BlockSize>512</n1:BlockSize>
<n1:Bootable xsi:nil="true"/>
<n1:Caption xsi:nil="true"/>
<n1:CommunicationStatus xsi:nil="true"/>
<n1:CompressionRate>1</n1:CompressionRate>
<n1:CompressionState xsi:nil="true"/>
<n1:ConsumableBlocks>2095104</n1:ConsumableBlocks>
<n1:CreationClassName>LMI_DiskPartition</n1:CreationClassName>
<n1:DataOrganization xsi:nil="true"/>
<n1:DataRedundancy>1</n1:DataRedundancy>
<n1:DeltaReservation xsi:nil="true"/>
<n1:Description xsi:nil="true"/>
<n1:DetailedStatus xsi:nil="true"/>
<n1:DeviceBusType xsi:nil="true"/>
<n1:DeviceID>/dev/disk/by-path/pci-0000:00:10.0-scsi-0:0:0:0-part3</n1:DeviceID>
<n1:ElementName>sda3</n1:ElementName>
<n1:EnabledDefault>2</n1:EnabledDefault>
<n1:EnabledState>5</n1:EnabledState>
<n1:ErrorCleared xsi:nil="true"/>
<n1:ErrorDescription xsi:nil="true"/>
<n1:ErrorMethodology xsi:nil="true"/>
<n1:Extendable xsi:nil="true"/>
<n1:ExtentInterleaveDepth xsi:nil="true"/>
<n1:ExtentStripeLength>1</n1:ExtentStripeLength>
<n1:Generation xsi:nil="true"/>
<n1:HealthState xsi:nil="true"/>
<n1:InstallDate xsi:nil="true"/>
<n1:InstanceID>LMI:LMI_DiskPartition:/dev/disk/by-path/pci-0000:00:10.0-scsi-0:0:0:0-part3</n1:InstanceID>
<n1:IsBasedOnUnderlyingRedundancy xsi:nil="true"/>
<n1:IsComposite>false</n1:IsComposite>
<n1:IsCompressed xsi:nil="true"/>
<n1:IsConcatenated xsi:nil="true"/>
<n1:LastErrorCode xsi:nil="true"/>
<n1:LocationIndicator xsi:nil="true"/>
<n1:MaxQuiesceTime xsi:nil="true"/>
<n1:Name>/dev/sda3</n1:Name>
<n1:NameFormat>12</n1:NameFormat>
<n1:NameNamespace>8</n1:NameNamespace>
<n1:Names>/dev/sda3</n1:Names>
<n1:Names>/dev/disk/by-path/pci-0000:00:10.0-scsi-0:0:0:0-part3</n1:Names>
<n1:Names>/dev/disk/by-uuid/4127bbee-bdfb-4266-baac-b39bb80813ad</n1:Names>
<n1:NoSinglePointOfFailure>false</n1:NoSinglePointOfFailure>
<n1:NumberOfBlocks>2095104</n1:NumberOfBlocks>
<n1:OperatingStatus xsi:nil="true"/>
<n1:OperationalStatus>2</n1:OperationalStatus>
<n1:OtherEnabledState xsi:nil="true"/>
<n1:OtherNameFormat xsi:nil="true"/>
<n1:OtherNameNamespace xsi:nil="true"/>
<n1:OtherUsageDescription xsi:nil="true"/>
<n1:PackageRedundancy>0</n1:PackageRedundancy>
<n1:PartitionSubtype xsi:nil="true"/>
<n1:PartitionType>1</n1:PartitionType>
<n1:PowerManagementSupported xsi:nil="true"/>
<n1:PowerOnHours xsi:nil="true"/>
<n1:PrimaryPartition>true</n1:PrimaryPartition>
<n1:PrimaryStatus xsi:nil="true"/>
<n1:Primordial>false</n1:Primordial>
<n1:Purpose xsi:nil="true"/>
<n1:RequestedState>12</n1:RequestedState>
<n1:SequentialAccess xsi:nil="true"/>
<n1:Signature xsi:nil="true"/>
<n1:SignatureAlgorithm xsi:nil="true"/>
<n1:SignatureState xsi:nil="true"/>
<n1:Status xsi:nil="true"/>
<n1:StatusInfo xsi:nil="true"/>
<n1:SystemCreationClassName>PG_ComputerSystem</n1:SystemCreationClassName>
<n1:SystemName>localhost</n1:SystemName>
<n1:TimeOfLastStateChange xsi:nil="true"/>
<n1:TotalPowerOnHours xsi:nil="true"/>
<n1:TransitioningToState>12</n1:TransitioningToState>
<n1:Usage xsi:nil="true"/>
</n1:LMI_DiskPartition>
</wsen:Items>
<wsen:EndOfSequence/>
</wsen:PullResponse>
</s:Body>
</s:Envelope>
Mi lehet a gond?
Előre is köszönöm!