drapple
4. November 2017 um 20:25
1
Hi ich lese aus der CCU 2 Daten aus, die bekomme ich dann als XML Format:
SimpleXMLElement Object
(
[Device] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => Badezimmer-OG Heizung
[Interface] => HmIP-RF
)
[Channel] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => Badezimmer-OG Heizung:0
[Address] => 000E57098F2281:0
[ChnLabel] => MAINTENANCE
)
[Point] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2281:0.CONFIG_PENDING
)
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2281:0.DUTY_CYCLE
)
)
[2] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2281:0.LOW_BAT
)
)
[3] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2281:0.OPERATING_VOLTAGE
)
)
[4] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2281:0.RSSI_DEVICE
)
)
[5] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2281:0.RSSI_PEER
)
)
[6] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2281:0.UNREACH
)
)
[7] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2281:0.UPDATE_PENDING
)
)
)
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => Badezimmer-OG Heizung
[Address] => 000E57098F2281:1
[ChnLabel] => HEATING_CLIMATECONTROL_TRANSCEIVER
)
Das nur ein Ausschnitt !
Wie bekomme ich nun die Einzelnen Werte in eine Variable ?
Könnt jemand mir ein Bespiel für Name, Adresse und ChnLabel posten ?
Fonzo
4. November 2017 um 20:46
2
drapple:
Wie bekomme ich nun die Einzelnen Werte in eine Variable ?
Könnt jemand mir ein Bespiel für Name, Adresse und ChnLabel posten ?
Grundlegende SimpleXML Verwendung
drapple
4. November 2017 um 20:48
3
Danke so schlau war ich auch schon…
Ich kann damit nichts anfangen…
Mit einem Beispiel komme viel besser klar…
Fonzo
4. November 2017 um 20:56
4
Poste mal das Original XML dann kann man Dir besser ein Beispiel geben.
drapple
4. November 2017 um 20:57
5
Gerne hier:
SimpleXMLElement Object
(
[Room] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => Bad-DG
)
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => Badezimmer-OG
)
)
[2] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => Flur-OG
)
)
[3] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => roomBedroom
)
)
[4] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => roomChildrensRoom1
)
)
[5] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => roomChildrensRoom2
)
)
[6] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => roomGarage
)
)
[7] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => roomGarden
)
)
[8] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => roomHWR
)
)
[9] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => roomKitchen
)
)
[10] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => roomLivingRoom
)
)
[11] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => roomOffice
)
)
[12] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => roomTerrace
)
)
)
[Function] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => funcButton
)
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => funcCentral
)
)
[2] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => funcClimateControl
)
)
[3] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => funcEnergy
)
)
[4] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => funcEnvironment
)
)
[5] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => funcHeating
)
)
[6] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => funcLight
)
)
[7] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => funcLock
)
)
[8] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => funcSecurity
)
)
[9] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => funcWeather
)
)
)
[Device] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => Badezimmer-OG Heizung
[Interface] => HmIP-RF
)
[Channel] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => Badezimmer-OG Heizung:0
[Address] => 000E57098F2281:0
[ChnLabel] => MAINTENANCE
)
[Point] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2281:0.CONFIG_PENDING
)
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2281:0.DUTY_CYCLE
)
)
[2] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2281:0.LOW_BAT
)
)
[3] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2281:0.OPERATING_VOLTAGE
)
)
[4] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2281:0.RSSI_DEVICE
)
)
[5] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2281:0.RSSI_PEER
)
)
[6] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2281:0.UNREACH
)
)
[7] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2281:0.UPDATE_PENDING
)
)
)
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => Badezimmer-OG Heizung
[Address] => 000E57098F2281:1
[ChnLabel] => HEATING_CLIMATECONTROL_TRANSCEIVER
)
[Function] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => funcHeating
)
)
[Room] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => Badezimmer-OG
)
)
[Point] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2281:1.ACTIVE_PROFILE
)
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2281:1.ACTUAL_TEMPERATURE
)
)
[2] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2281:1.BOOST_MODE
)
)
[3] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2281:1.BOOST_TIME
)
)
[4] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2281:1.CONTROL_DIFFERENTIAL_TEMPERATURE
)
)
[5] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2281:1.CONTROL_MODE
)
)
[6] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2281:1.DURATION_UNIT
)
)
[7] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2281:1.DURATION_VALUE
)
)
[8] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2281:1.FROST_PROTECTION
)
)
[9] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2281:1.HEATING_COOLING
)
)
[10] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2281:1.HUMIDITY
)
)
[11] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2281:1.PARTY_MODE
)
)
[12] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2281:1.PARTY_SET_POINT_TEMPERATURE
)
)
[13] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2281:1.PARTY_TIME_END
)
)
[14] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2281:1.PARTY_TIME_START
)
)
[15] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2281:1.SET_POINT_MODE
)
)
[16] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2281:1.SET_POINT_TEMPERATURE
)
)
[17] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2281:1.SWITCH_POINT_OCCURED
)
)
[18] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2281:1.WINDOW_STATE
)
)
)
)
[2] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => Badezimmer-OG Heizung 1
[Address] => 000E57098F2281:2
[ChnLabel] => HEATING_CLIMATECONTROL_RECEIVER
)
[Function] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => funcHeating
)
)
[Room] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => Badezimmer-OG
)
)
)
[3] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => Badezimmer-OG Heizung 2
[Address] => 000E57098F2281:3
[ChnLabel] => HEATING_CLIMATECONTROL_CL_TRANSMITTER
)
[Function] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => funcHeating
)
)
[Room] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => Badezimmer-OG
)
)
)
[4] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => Badezimmer-OG Heizung 3
[Address] => 000E57098F2281:4
[ChnLabel] => HEATING_SHUTTER_CONTACT_RECEIVER
)
[Function] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => funcHeating
)
)
[Room] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => Badezimmer-OG
)
)
)
[5] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => Badezimmer-OG Heizung 4
[Address] => 000E57098F2281:5
[ChnLabel] => HEATING_CLIMATECONTROL_SWITCH_TRANSMITTER
)
[Function] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => funcHeating
)
)
[Room] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => Badezimmer-OG
)
)
)
[6] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => Badezimmer-OG Heizung 5
[Address] => 000E57098F2281:6
[ChnLabel] => HEATING_KEY_RECEIVER
)
[Function] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => funcHeating
)
)
[Room] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => Badezimmer-OG
)
)
)
[7] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => Badezimmer-OG Heizung 6
[Address] => 000E57098F2281:7
[ChnLabel] => CLIMATECONTROL_FLOOR_TRANSMITTER
)
[Function] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => funcHeating
)
)
[Room] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => Badezimmer-OG
)
)
)
)
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => Fussbodenheizung
[Interface] => HmIP-RF
)
[Channel] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => Fussbodenheizung:0
[Address] => 0005970997E6EF:0
[ChnLabel] => MAINTENANCE
)
[Point] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:0.CONFIG_PENDING
)
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:0.DATE_TIME_UNKNOWN
)
)
[2] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:0.DUTY_CYCLE
)
)
[3] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:0.HEATING_COOLING
)
)
[4] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:0.HUMIDITY_ALARM
)
)
[5] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:0.OPERATING_VOLTAGE
)
)
[6] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:0.RSSI_DEVICE
)
)
[7] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:0.RSSI_PEER
)
)
[8] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:0.TEMPERATURE_LIMITER
)
)
[9] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:0.UNREACH
)
)
[10] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:0.UPDATE_PENDING
)
)
)
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-FAL230-C6 0005970997E6EF:1
[Address] => 0005970997E6EF:1
[ChnLabel] => CLIMATECONTROL_FLOOR_PUMP_TRANSCEIVER
)
[Room] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => roomLivingRoom
)
)
[Point] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:1.DEW_POINT_ALARM
)
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:1.EMERGENCY_OPERATION
)
)
[2] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:1.EXTERNAL_CLOCK
)
)
[3] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:1.FROST_PROTECTION
)
)
[4] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:1.HUMIDITY_LIMITER
)
)
[5] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:1.STATE
)
)
)
)
[2] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-FAL230-C6 0005970997E6EF:2
[Address] => 0005970997E6EF:2
[ChnLabel] => CLIMATECONTROL_FLOOR_TRANSCEIVER
)
[Room] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => Badezimmer-OG
)
)
[Point] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:2.DEW_POINT_ALARM
)
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:2.EMERGENCY_OPERATION
)
)
[2] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:2.EXTERNAL_CLOCK
)
)
[3] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:2.FROST_PROTECTION
)
)
[4] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:2.HUMIDITY_LIMITER
)
)
[5] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:2.STATE
)
)
)
)
[3] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-FAL230-C6 0005970997E6EF:3
[Address] => 0005970997E6EF:3
[ChnLabel] => CLIMATECONTROL_FLOOR_TRANSCEIVER
)
[Room] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => roomBedroom
)
)
[Point] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:3.DEW_POINT_ALARM
)
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:3.EMERGENCY_OPERATION
)
)
[2] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:3.EXTERNAL_CLOCK
)
)
[3] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:3.FROST_PROTECTION
)
)
[4] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:3.HUMIDITY_LIMITER
)
)
[5] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:3.STATE
)
)
)
)
[4] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-FAL230-C6 0005970997E6EF:4
[Address] => 0005970997E6EF:4
[ChnLabel] => CLIMATECONTROL_FLOOR_TRANSCEIVER
)
[Room] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => Flur-OG
)
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => roomKitchen
)
)
[2] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => roomOffice
)
)
)
[Point] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:4.DEW_POINT_ALARM
)
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:4.EMERGENCY_OPERATION
)
)
[2] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:4.EXTERNAL_CLOCK
)
)
[3] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:4.FROST_PROTECTION
)
)
[4] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:4.HUMIDITY_LIMITER
)
)
[5] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:4.STATE
)
)
)
)
[5] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-FAL230-C6 0005970997E6EF:5
[Address] => 0005970997E6EF:5
[ChnLabel] => CLIMATECONTROL_FLOOR_TRANSCEIVER
)
[Point] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:5.DEW_POINT_ALARM
)
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:5.EMERGENCY_OPERATION
)
)
[2] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:5.EXTERNAL_CLOCK
)
)
[3] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:5.FROST_PROTECTION
)
)
[4] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:5.HUMIDITY_LIMITER
)
)
[5] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:5.STATE
)
)
)
)
[6] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-FAL230-C6 0005970997E6EF:6
[Address] => 0005970997E6EF:6
[ChnLabel] => CLIMATECONTROL_FLOOR_TRANSCEIVER
)
[Point] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:6.DEW_POINT_ALARM
)
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:6.EMERGENCY_OPERATION
)
)
[2] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:6.EXTERNAL_CLOCK
)
)
[3] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:6.FROST_PROTECTION
)
)
[4] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:6.HUMIDITY_LIMITER
)
)
[5] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.0005970997E6EF:6.STATE
)
)
)
)
[7] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-FAL230-C6 0005970997E6EF:7
[Address] => 0005970997E6EF:7
[ChnLabel] => CLIMATECONTROL_HEAT_DEMAND_BOILER_TRANSMITTER
)
[0] =>
)
[8] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-FAL230-C6 0005970997E6EF:8
[Address] => 0005970997E6EF:8
[ChnLabel] => CLIMATECONTROL_HEAT_DEMAND_PUMP_TRANSMITTER
)
[0] =>
)
[9] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-FAL230-C6 0005970997E6EF:9
[Address] => 0005970997E6EF:9
[ChnLabel] => CLIMATECONTROL_DEHUMIDIFIER_TRANSMITER
)
[0] =>
)
)
)
[2] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => Heizung Küche
[Interface] => HmIP-RF
)
[Channel] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => Heizung Küche:0
[Address] => 000E57098F2249:0
[ChnLabel] => MAINTENANCE
)
[Point] => Array
(
[0] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2249:0.CONFIG_PENDING
)
)
[1] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2249:0.DUTY_CYCLE
)
)
[2] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2249:0.LOW_BAT
)
)
[3] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2249:0.OPERATING_VOLTAGE
)
)
[4] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2249:0.RSSI_DEVICE
)
)
[5] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => HmIP-RF.000E57098F2249:0.RSSI_PEER
)
)
[6] => SimpleXMLElement Object
(
[@attributes] => Array
(
...
[ChnLabel] => CLIMATECONTROL_FLOOR_TRANSMITTER
)
[Function] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => funcHeating
)
)
[Room] => SimpleXMLElement Object
(
[@attributes] => Array
(
[Name] => roomLivingRoom
)
)
)
)
)
)
)
Fonzo
4. November 2017 um 21:17
6
drapple:
Gerne hier:
Ich meinte eher das XML selber, also das was Du ausliest, das kann man nämlich auf den ersten Blick besser lesen.
$xml = new SimpleXMLElement($string);
echo $xml->asXML();
$xml->Device[0][‚Name‘]
So aus dem Kopf.
Wobei natürlich foreach auf $xml und dann auch auf Channel sinnvoll ist.
Foreach ($xml AS $Device)
{
Echo $Device['Name']; // Gerätename
Echo $Device->Channel[0]['Name']; // Kanalname
Foreach ($Device as $Channel)
{
Echo $Channel['Name']; // nochmal Kanalname
Echo $Channel['Address'];
}
}
Michael
oder alles in ein Array konvertieren:
ich gehe davon aus, dass $result ein SimpleXMLElement ist.
$result = json_decode(json_encode((array) ($result)), 1);
Wenn $result noch kein SimpleXMLElement ist, dann
$result = json_decode(json_encode((array) simplexml_load_string($result)), 1);
Dann musst du das Array auswerten.
Ich glaube bei einen einfachen cast auf Array werden aber die Attribute nicht in das Array übernommen.
Einfach mal ausprobieren
Es ist ja nicht nur ein SimpleXMLElement; es enthält ja auch weitere Array mit weiteren SimpleXMLElementen.
Michael
PS: Korrekterweise ist der zweite Parameter bei json_decode ein bool.
$result = json_decode(json_encode((array) ($result)), true);
In einem Beispiel von mir (hat nichts mit HomeMatic zu tun), funktioniert es, müsste auch mehrdimensional sein:
Array
(
[@attributes] => Array
(
[deviceID] => 1234567890
)
[sourceItem] => Array
(
[0] => AUX IN
[1] => DS216
[2] => iTunes
[3] => Array
(
[@attributes] => Array
(
[source] => INTERNET_RADIO
[status] => READY
[isLocal] => false
[multiroomallowed] => true
)
)
[4] => Array
(
[@attributes] => Array
(
[source] => NOTIFICATION
[status] => UNAVAILABLE
[isLocal] => false
[multiroomallowed] => true
)
)
[5] => Array
(
[@attributes] => Array
(
[source] => BLUETOOTH
[status] => UNAVAILABLE
[isLocal] => true
[multiroomallowed] => true
)
)
[6] => UPnPUserName
[7] => QPlay1UserName
[8] => QPlay2UserName
[9] => StoredMusicUserName
[10] => eMail
[11] => Array
(
[@attributes] => Array
(
[source] => SPOTIFY
[status] => UNAVAILABLE
[isLocal] => false
[multiroomallowed] => true
)
)
[12] => Array
(
[@attributes] => Array
(
[source] => TUNEIN
[status] => READY
[isLocal] => false
[multiroomallowed] => true
)
)
)
)
Für die Werte, die ich auslesen will nutze ich auch foreach.
Den Wert „INTERNET_RADIO“ kann ich also auslesen.
Uli
PS: 1 = true
Cool, die Attribute werden dann in den Index ‚@attributes ‘ abgelegt.
Wobei es ja Grundsätzlich egal ist, ob man nun mit Objekten oder Arrays arbeitet.
Solange man weiß wie man auf dessen Eigenschaften und Werte zugreifen kann.
Nur wenn man z.B. wieder auf Methoden vom Objekt zugreifen will, ist das mit einen Array nicht möglich. Ist hier aber auch nicht relevant.
Michael
drapple
6. November 2017 um 08:08
12
Danke für euere Hilfe, aber leider klappt das
$string=ReadCCUInterfaces("192.168.0.79");
$result = json_decode(json_encode((array) ($string)), true);
Ausgabe:
Array
(
[Interface] => Array
(
[0] => Array
(
[@attributes] => Array
(
[Name] => BidCos-RF
[Address] => 1007
)
)
[1] => Array
(
[@attributes] => Array
(
[Name] => VirtualDevices
[Address] => 1008
)
)
[2] => Array
(
[@attributes] => Array
(
[Name] => HmIP-RF
[Address] => 1628
)
)
)
)
oder so:
Foreach ($string AS $Device)
{
Echo $Device['Name']; // Gerätename
Echo $Device->Channel[0]['Name']; // Kanalname
Foreach ($Device as $Channel)
{
Echo $Channel['Name']; // nochmal Kanalname
Echo $Channel['Address'];
}
}
Ausgabe:
BidCos-RFVirtualDevicesHmIP-RF
Was läuft schief ?
Kann es sein, das nur Geräte die erreichbar sind auch ausgelesen werden ?
ReadCCUInterfaces liest nur die Interfaces aus, nicht die Geräte
Michael
drapple
6. November 2017 um 08:34
14
Danke habe ich auch gemerkt eben danke…