Загрузка нестандартных xml-данных wsman в объект с php

На этот вопрос был дан ответ во многих вариантах, но ни один из них не касается моей ситуации.

Я вытягиваю данные с помощью WSMan, который затем возвращает результат как своего рода sudo-xml. Я бы даже не считал это «настоящим» xml, так как у него так много нестандартных атрибутов. Проблема в том, что мне нужно иметь возможность ссылаться на результат как на объект внутри PHP. Поэтому на данный момент я использую много str_replace. Проблема в том, что если нестандартный формат отклоняется (в некоторых случаях он возвращает что-то вроде этого <KeyID xsi:nil="true"/> в других случаях это может быть что-то вроде этого <CMCIP xsi:nil="true"/> ), трудно предвидеть все разные атрибуты, которые мне придется учитывать и вытащить из переменной перед импортом в качестве объекта с помощью simplexml_load_string.

Итак, мой вопрос во всей простоте: есть ли способ загрузить нестандартный XML в объект? Вот пример данных xml, так что вы знаете, какое безумие мы имеем здесь.

 <?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"> <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/EnumerateResponse</wsa:Action> <wsa:RelatesTo>uuid:3ae2d181-04f0-14f0-8002-89040b5d1500</wsa:RelatesTo> <wsa:MessageID>uuid:43a291ab-04f0-14f0-8073-b516f1d9bed4</wsa:MessageID> </s:Header> <s:Body> <wsen:EnumerateResponse> <wsen:EnumerationContext>439c90e9-04f0-14f0-8072-b516f1d9bed4</wsen:EnumerationContext> </wsen:EnumerateResponse> </s:Body> </s:Envelope> <?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.dell.com/wbem/wscim/1/cim-schema/2/DCIM_SystemView" 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:3af0a1eb-04f0-14f0-8003-89040b5d1500</wsa:RelatesTo> <wsa:MessageID>uuid:43a41fe8-04f0-14f0-8074-b516f1d9bed4</wsa:MessageID> </s:Header> <s:Body> <wsen:PullResponse> <wsen:Items> <n1:DCIM_SystemView> <n1:AssetTag/> <n1:BIOSReleaseDate>11/20/2013</n1:BIOSReleaseDate> <n1:BIOSVersionString>2.1.3</n1:BIOSVersionString> <n1:BaseBoardChassisSlot>NA</n1:BaseBoardChassisSlot> <n1:BatteryRollupStatus>1</n1:BatteryRollupStatus> <n1:BladeGeometry>255</n1:BladeGeometry> <n1:BoardPartNumber>061P35A00</n1:BoardPartNumber> <n1:BoardSerialNumber>CN70163231007K</n1:BoardSerialNumber> <n1:CMCIP xsi:nil="true"/> <n1:CPLDVersion>1.0.3</n1:CPLDVersion> <n1:CPURollupStatus>1</n1:CPURollupStatus> <n1:ChassisModel/> <n1:ChassisName>Main System Chassis</n1:ChassisName> <n1:ChassisServiceTag>REMOVED</n1:ChassisServiceTag> <n1:ChassisSystemHeight>2</n1:ChassisSystemHeight> <n1:DeviceDescription>System</n1:DeviceDescription> <n1:ExpressServiceCode>33088672189</n1:ExpressServiceCode> <n1:FQDD>System.Embedded.1</n1:FQDD> <n1:FanRollupStatus>1</n1:FanRollupStatus> <n1:HostName/> <n1:InstanceID>System.Embedded.1</n1:InstanceID> <n1:LastSystemInventoryTime>20140928010936.000000+000</n1:LastSystemInventoryTime> <n1:LastUpdateTime>20140220171215.000000+000</n1:LastUpdateTime> <n1:LicensingRollupStatus>1</n1:LicensingRollupStatus> <n1:LifecycleControllerVersion>2.1.0</n1:LifecycleControllerVersion> <n1:Manufacturer>Dell Inc.</n1:Manufacturer> <n1:MaxCPUSockets>2</n1:MaxCPUSockets> <n1:MaxDIMMSlots>24</n1:MaxDIMMSlots> <n1:MaxPCIeSlots>6</n1:MaxPCIeSlots> <n1:MemoryOperationMode>OptimizerMode</n1:MemoryOperationMode> <n1:Model>PowerEdge R720xd</n1:Model> <n1:NodeID>F7852V1</n1:NodeID> <n1:PSRollupStatus>1</n1:PSRollupStatus> <n1:PlatformGUID>3156324f-c0c6-3580-3810-00374c4c4544</n1:PlatformGUID> <n1:PopulatedCPUSockets>2</n1:PopulatedCPUSockets> <n1:PopulatedDIMMSlots>8</n1:PopulatedDIMMSlots> <n1:PopulatedPCIeSlots>2</n1:PopulatedPCIeSlots> <n1:PowerCap>598</n1:PowerCap> <n1:PowerCapEnabledState>3</n1:PowerCapEnabledState> <n1:PowerState>2</n1:PowerState> <n1:PrimaryStatus>1</n1:PrimaryStatus> <n1:RollupStatus>1</n1:RollupStatus> <n1:ServerAllocation xsi:nil="true"/> <n1:ServiceTag>REMOVED</n1:ServiceTag> <n1:StorageRollupStatus>1</n1:StorageRollupStatus> <n1:SysMemErrorMethodology>6</n1:SysMemErrorMethodology> <n1:SysMemFailOverState>NotInUse</n1:SysMemFailOverState> <n1:SysMemLocation>3</n1:SysMemLocation> <n1:SysMemMaxCapacitySize>1572864</n1:SysMemMaxCapacitySize> <n1:SysMemPrimaryStatus>1</n1:SysMemPrimaryStatus> <n1:SysMemTotalSize>65536</n1:SysMemTotalSize> <n1:SystemGeneration>12G Monolithic</n1:SystemGeneration> <n1:SystemID>1320</n1:SystemID> <n1:SystemRevision>0</n1:SystemRevision> <n1:TempRollupStatus>1</n1:TempRollupStatus> <n1:UUID>4c4c4544-0037-3810-8035-c6c04f325631</n1:UUID> <n1:VoltRollupStatus>1</n1:VoltRollupStatus> <n1:smbiosGUID>44454c4c-3700-1038-8035-c6c04f325631</n1:smbiosGUID> </n1:DCIM_SystemView> </wsen:Items> <wsen:EndOfSequence/> </wsen:PullResponse> </s:Body> </s:Envelope> состояния <?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"> <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/EnumerateResponse</wsa:Action> <wsa:RelatesTo>uuid:3ae2d181-04f0-14f0-8002-89040b5d1500</wsa:RelatesTo> <wsa:MessageID>uuid:43a291ab-04f0-14f0-8073-b516f1d9bed4</wsa:MessageID> </s:Header> <s:Body> <wsen:EnumerateResponse> <wsen:EnumerationContext>439c90e9-04f0-14f0-8072-b516f1d9bed4</wsen:EnumerationContext> </wsen:EnumerateResponse> </s:Body> </s:Envelope> <?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.dell.com/wbem/wscim/1/cim-schema/2/DCIM_SystemView" 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:3af0a1eb-04f0-14f0-8003-89040b5d1500</wsa:RelatesTo> <wsa:MessageID>uuid:43a41fe8-04f0-14f0-8074-b516f1d9bed4</wsa:MessageID> </s:Header> <s:Body> <wsen:PullResponse> <wsen:Items> <n1:DCIM_SystemView> <n1:AssetTag/> <n1:BIOSReleaseDate>11/20/2013</n1:BIOSReleaseDate> <n1:BIOSVersionString>2.1.3</n1:BIOSVersionString> <n1:BaseBoardChassisSlot>NA</n1:BaseBoardChassisSlot> <n1:BatteryRollupStatus>1</n1:BatteryRollupStatus> <n1:BladeGeometry>255</n1:BladeGeometry> <n1:BoardPartNumber>061P35A00</n1:BoardPartNumber> <n1:BoardSerialNumber>CN70163231007K</n1:BoardSerialNumber> <n1:CMCIP xsi:nil="true"/> <n1:CPLDVersion>1.0.3</n1:CPLDVersion> <n1:CPURollupStatus>1</n1:CPURollupStatus> <n1:ChassisModel/> <n1:ChassisName>Main System Chassis</n1:ChassisName> <n1:ChassisServiceTag>REMOVED</n1:ChassisServiceTag> <n1:ChassisSystemHeight>2</n1:ChassisSystemHeight> <n1:DeviceDescription>System</n1:DeviceDescription> <n1:ExpressServiceCode>33088672189</n1:ExpressServiceCode> <n1:FQDD>System.Embedded.1</n1:FQDD> <n1:FanRollupStatus>1</n1:FanRollupStatus> <n1:HostName/> <n1:InstanceID>System.Embedded.1</n1:InstanceID> <n1:LastSystemInventoryTime>20140928010936.000000+000</n1:LastSystemInventoryTime> <n1:LastUpdateTime>20140220171215.000000+000</n1:LastUpdateTime> <n1:LicensingRollupStatus>1</n1:LicensingRollupStatus> <n1:LifecycleControllerVersion>2.1.0</n1:LifecycleControllerVersion> <n1:Manufacturer>Dell Inc.</n1:Manufacturer> <n1:MaxCPUSockets>2</n1:MaxCPUSockets> <n1:MaxDIMMSlots>24</n1:MaxDIMMSlots> <n1:MaxPCIeSlots>6</n1:MaxPCIeSlots> <n1:MemoryOperationMode>OptimizerMode</n1:MemoryOperationMode> <n1:Model>PowerEdge R720xd</n1:Model> <n1:NodeID>F7852V1</n1:NodeID> <n1:PSRollupStatus>1</n1:PSRollupStatus> <n1:PlatformGUID>3156324f-c0c6-3580-3810-00374c4c4544</n1:PlatformGUID> <n1:PopulatedCPUSockets>2</n1:PopulatedCPUSockets> <n1:PopulatedDIMMSlots>8</n1:PopulatedDIMMSlots> <n1:PopulatedPCIeSlots>2</n1:PopulatedPCIeSlots> <n1:PowerCap>598</n1:PowerCap> <n1:PowerCapEnabledState>3</n1:PowerCapEnabledState> <n1:PowerState>2</n1:PowerState> <n1:PrimaryStatus>1</n1:PrimaryStatus> <n1:RollupStatus>1</n1:RollupStatus> <n1:ServerAllocation xsi:nil="true"/> <n1:ServiceTag>REMOVED</n1:ServiceTag> <n1:StorageRollupStatus>1</n1:StorageRollupStatus> <n1:SysMemErrorMethodology>6</n1:SysMemErrorMethodology> <n1:SysMemFailOverState>NotInUse</n1:SysMemFailOverState> <n1:SysMemLocation>3</n1:SysMemLocation> <n1:SysMemMaxCapacitySize>1572864</n1:SysMemMaxCapacitySize> <n1:SysMemPrimaryStatus>1</n1:SysMemPrimaryStatus> <n1:SysMemTotalSize>65536</n1:SysMemTotalSize> <n1:SystemGeneration>12G Monolithic</n1:SystemGeneration> <n1:SystemID>1320</n1:SystemID> <n1:SystemRevision>0</n1:SystemRevision> <n1:TempRollupStatus>1</n1:TempRollupStatus> <n1:UUID>4c4c4544-0037-3810-8035-c6c04f325631</n1:UUID> <n1:VoltRollupStatus>1</n1:VoltRollupStatus> <n1:smbiosGUID>44454c4c-3700-1038-8035-c6c04f325631</n1:smbiosGUID> </n1:DCIM_SystemView> </wsen:Items> <wsen:EndOfSequence/> </wsen:PullResponse> </s:Body> </s:Envelope> состояния <?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"> <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/EnumerateResponse</wsa:Action> <wsa:RelatesTo>uuid:3ae2d181-04f0-14f0-8002-89040b5d1500</wsa:RelatesTo> <wsa:MessageID>uuid:43a291ab-04f0-14f0-8073-b516f1d9bed4</wsa:MessageID> </s:Header> <s:Body> <wsen:EnumerateResponse> <wsen:EnumerationContext>439c90e9-04f0-14f0-8072-b516f1d9bed4</wsen:EnumerationContext> </wsen:EnumerateResponse> </s:Body> </s:Envelope> <?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.dell.com/wbem/wscim/1/cim-schema/2/DCIM_SystemView" 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:3af0a1eb-04f0-14f0-8003-89040b5d1500</wsa:RelatesTo> <wsa:MessageID>uuid:43a41fe8-04f0-14f0-8074-b516f1d9bed4</wsa:MessageID> </s:Header> <s:Body> <wsen:PullResponse> <wsen:Items> <n1:DCIM_SystemView> <n1:AssetTag/> <n1:BIOSReleaseDate>11/20/2013</n1:BIOSReleaseDate> <n1:BIOSVersionString>2.1.3</n1:BIOSVersionString> <n1:BaseBoardChassisSlot>NA</n1:BaseBoardChassisSlot> <n1:BatteryRollupStatus>1</n1:BatteryRollupStatus> <n1:BladeGeometry>255</n1:BladeGeometry> <n1:BoardPartNumber>061P35A00</n1:BoardPartNumber> <n1:BoardSerialNumber>CN70163231007K</n1:BoardSerialNumber> <n1:CMCIP xsi:nil="true"/> <n1:CPLDVersion>1.0.3</n1:CPLDVersion> <n1:CPURollupStatus>1</n1:CPURollupStatus> <n1:ChassisModel/> <n1:ChassisName>Main System Chassis</n1:ChassisName> <n1:ChassisServiceTag>REMOVED</n1:ChassisServiceTag> <n1:ChassisSystemHeight>2</n1:ChassisSystemHeight> <n1:DeviceDescription>System</n1:DeviceDescription> <n1:ExpressServiceCode>33088672189</n1:ExpressServiceCode> <n1:FQDD>System.Embedded.1</n1:FQDD> <n1:FanRollupStatus>1</n1:FanRollupStatus> <n1:HostName/> <n1:InstanceID>System.Embedded.1</n1:InstanceID> <n1:LastSystemInventoryTime>20140928010936.000000+000</n1:LastSystemInventoryTime> <n1:LastUpdateTime>20140220171215.000000+000</n1:LastUpdateTime> <n1:LicensingRollupStatus>1</n1:LicensingRollupStatus> <n1:LifecycleControllerVersion>2.1.0</n1:LifecycleControllerVersion> <n1:Manufacturer>Dell Inc.</n1:Manufacturer> <n1:MaxCPUSockets>2</n1:MaxCPUSockets> <n1:MaxDIMMSlots>24</n1:MaxDIMMSlots> <n1:MaxPCIeSlots>6</n1:MaxPCIeSlots> <n1:MemoryOperationMode>OptimizerMode</n1:MemoryOperationMode> <n1:Model>PowerEdge R720xd</n1:Model> <n1:NodeID>F7852V1</n1:NodeID> <n1:PSRollupStatus>1</n1:PSRollupStatus> <n1:PlatformGUID>3156324f-c0c6-3580-3810-00374c4c4544</n1:PlatformGUID> <n1:PopulatedCPUSockets>2</n1:PopulatedCPUSockets> <n1:PopulatedDIMMSlots>8</n1:PopulatedDIMMSlots> <n1:PopulatedPCIeSlots>2</n1:PopulatedPCIeSlots> <n1:PowerCap>598</n1:PowerCap> <n1:PowerCapEnabledState>3</n1:PowerCapEnabledState> <n1:PowerState>2</n1:PowerState> <n1:PrimaryStatus>1</n1:PrimaryStatus> <n1:RollupStatus>1</n1:RollupStatus> <n1:ServerAllocation xsi:nil="true"/> <n1:ServiceTag>REMOVED</n1:ServiceTag> <n1:StorageRollupStatus>1</n1:StorageRollupStatus> <n1:SysMemErrorMethodology>6</n1:SysMemErrorMethodology> <n1:SysMemFailOverState>NotInUse</n1:SysMemFailOverState> <n1:SysMemLocation>3</n1:SysMemLocation> <n1:SysMemMaxCapacitySize>1572864</n1:SysMemMaxCapacitySize> <n1:SysMemPrimaryStatus>1</n1:SysMemPrimaryStatus> <n1:SysMemTotalSize>65536</n1:SysMemTotalSize> <n1:SystemGeneration>12G Monolithic</n1:SystemGeneration> <n1:SystemID>1320</n1:SystemID> <n1:SystemRevision>0</n1:SystemRevision> <n1:TempRollupStatus>1</n1:TempRollupStatus> <n1:UUID>4c4c4544-0037-3810-8035-c6c04f325631</n1:UUID> <n1:VoltRollupStatus>1</n1:VoltRollupStatus> <n1:smbiosGUID>44454c4c-3700-1038-8035-c6c04f325631</n1:smbiosGUID> </n1:DCIM_SystemView> </wsen:Items> <wsen:EndOfSequence/> </wsen:PullResponse> </s:Body> </s:Envelope> 

Solutions Collecting From Web of "Загрузка нестандартных xml-данных wsman в объект с php"