Hee allemaal!

Ik zit met een probleem in de maag. Ik wil namelijk een webpagina maken met een custom layout met informatie van mijn Hosting computer daarop. Ik heb op de hostingcomputer (externe url) PHPSysInfo geïnstalleerd en dat werkt fantastisch. Nu wil ik alleen via de XML van PHPSysInfo de gegevens op mijn website zetten. (Denk aan een balk met ruimte, enz.) Dus dat je niet de standaard PHPSysInfo in een iframe moet zetten ofzo, ziet er niet uit.

De XML van PHPSysInfo


Array
(
    [tns:phpsysinfo] => Array
        (
            [Generation] => Array
                (
                )

            [Generation_attr] => Array
                (
                    [version] => 3.1.2
                    [timestamp] => 1362769273
                )

            [Options] => Array
                (
                )

            [Options_attr] => Array
                (
                    [tempFormat] => c
                    [byteFormat] => auto_binary
                    [refresh] => 60000
                    [showPickListTemplate] => true
                    [showPickListLang] => true
                )

            [UsedPlugins] => Array
                (
                )

            [Vitals] => Array
                (
                )

            [Vitals_attr] => Array
                (
                    [Hostname] => *Hostname*
                    [IPAddr] => *IP*
                    [Kernel] => 6.1.7600
                    [Distro] => Microsoft Windows 7 Ultimate
                    [Distroicon] => WinVista.png
                    [Uptime] => 203268
                    [Users] => 1
                    [LoadAvg] => 38
                    [SysLang] => Dutch - Netherlands (1043)
                    [CodePage] => windows-1252
                )

            [Network] => Array
                (
                    [NetDevice] => Array
                        (
                            [0] => Array
                                (
                                )

                            [1] => Array
                                (
                                )

                            [0_attr] => Array
                                (
                                    [Name] => Intel[R] PRO_1000 MT-netwerkverbinding
                                    [RxBytes] => 957595725
                                    [TxBytes] => 1474000837
                                    [Err] => 0
                                    [Drops] => 0
                                )

                            [1_attr] => Array
                                (
                                    [Name] => Intel[R] PRO_1000 PM-netwerkverbinding
                                    [RxBytes] => 88822522
                                    [TxBytes] => 67779834
                                    [Err] => 0
                                    [Drops] => 29
                                )

                            [2] => Array
                                (
                                )

                            [2_attr] => Array
                                (
                                    [Name] => Intel[R] PRO_1000 GT Desktop-adapter
                                    [RxBytes] => 0
                                    [TxBytes] => 0
                                    [Err] => 0
                                    [Drops] => 0
                                )

                            [3] => Array
                                (
                                )

                            [3_attr] => Array
                                (
                                    [Name] => *Hostname*
                                    [RxBytes] => 0
                                    [TxBytes] => 0
                                    [Err] => 0
                                    [Drops] => 0
                                )

                            [4] => Array
                                (
                                )

                            [4_attr] => Array
                                (
                                    [Name] => Teredo Tunneling Pseudo-Interface
                                    [RxBytes] => 33760
                                    [TxBytes] => 30309
                                    [Err] => 0
                                    [Drops] => 0
                                )

                        )

                )

            [Hardware] => Array
                (
                    [PCI] => Array
                        (
                            [Device] => Array
                                (
                                    [0] => Array
                                        (
                                        )

                                    [1] => Array
                                        (
                                        )

                                    [0_attr] => Array
                                        (
                                            [Name] => Intel(R) PRO/1000 MT-netwerkverbinding
                                            [Count] => 1
                                        )

                                    [1_attr] => Array
                                        (
                                            [Name] => Intel(R) 82801GB/GR/GH (ICH7 Family) Serial ATA Storage Controller - 27C0
                                            [Count] => 1
                                        )

                                    [2] => Array
                                        (
                                        )

                                    [2_attr] => Array
                                        (
                                            [Name] => Intel(R) 82801G (ICH7 Family) Ultra ATA Storage Controllers - 27DF
                                            [Count] => 1
                                        )

                                    [3] => Array
                                        (
                                        )

                                    [3_attr] => Array
                                        (
                                            [Name] => Intel(R) PRO/1000 GT Desktop-adapter
                                            [Count] => 1
                                        )

                                    [4] => Array
                                        (
                                        )

                                    [4_attr] => Array
                                        (
                                            [Name] => Intel(R) 82801G (ICH7 Family) USB Universal Host Controller - 27C8
                                            [Count] => 1
                                        )

                                    [5] => Array
                                        (
                                        )

                                    [5_attr] => Array
                                        (
                                            [Name] => Intel(R) 82801GR/GH/GHM (ICH7 Family) PCI Express Root Port - 27E0
                                            [Count] => 1
                                        )

                                    [6] => Array
                                        (
                                        )

                                    [6_attr] => Array
                                        (
                                            [Name] => Intel(R) PRO/1000 PM-netwerkverbinding
                                            [Count] => 1
                                        )

                                    [7] => Array
                                        (
                                        )

                                    [7_attr] => Array
                                        (
                                            [Name] => Intel(R) 82801G (ICH7 Family) USB Universal Host Controller - 27C9
                                            [Count] => 1
                                        )

                                    [8] => Array
                                        (
                                        )

                                    [8_attr] => Array
                                        (
                                            [Name] => Intel(R) 82801GR/GH/GHM (ICH7 Family) PCI Express Root Port - 27E2
                                            [Count] => 1
                                        )

                                    [9] => Array
                                        (
                                        )

                                    [9_attr] => Array
                                        (
                                            [Name] => IPMI Interface
                                            [Count] => 1
                                        )

                                    [10] => Array
                                        (
                                        )

                                    [10_attr] => Array
                                        (
                                            [Name] => Intel(R) 82801G (ICH7 Family) USB Universal Host Controller - 27CA
                                            [Count] => 1
                                        )

                                    [11] => Array
                                        (
                                        )

                                    [11_attr] => Array
                                        (
                                            [Name] => PCI Serial Port
                                            [Count] => 1
                                        )

                                    [12] => Array
                                        (
                                        )

                                    [12_attr] => Array
                                        (
                                            [Name] => Intel(R) 82801G (ICH7 Family) USB Universal Host Controller - 27CB
                                            [Count] => 1
                                        )

                                    [13] => Array
                                        (
                                        )

                                    [13_attr] => Array
                                        (
                                            [Name] => Standaard-VGA grafische adapter
                                            [Count] => 1
                                        )

                                    [14] => Array
                                        (
                                        )

                                    [14_attr] => Array
                                        (
                                            [Name] => Intel(R) 82801 PCI Bridge - 244E
                                            [Count] => 1
                                        )

                                    [15] => Array
                                        (
                                        )

                                    [15_attr] => Array
                                        (
                                            [Name] => Intel(R) 82801G (ICH7 Family) USB2 Enhanced Host Controller - 27CC
                                            [Count] => 1
                                        )

                                    [16] => Array
                                        (
                                        )

                                    [16_attr] => Array
                                        (
                                            [Name] => Silicon Image SiI 3512 SATALink Controller
                                            [Count] => 1
                                        )

                                    [17] => Array
                                        (
                                        )

                                    [17_attr] => Array
                                        (
                                            [Name] => Intel(R) E7230/3000/3010 Processor to I/O Controller - 2778
                                            [Count] => 1
                                        )

                                    [18] => Array
                                        (
                                        )

                                    [18_attr] => Array
                                        (
                                            [Name] => Intel(R) 82801G (ICH7 Family) PCI Express Root Port - 27D0
                                            [Count] => 1
                                        )

                                    [19] => Array
                                        (
                                        )

                                    [19_attr] => Array
                                        (
                                            [Name] => Intel(R) 6702PXH PCI Express-to-PCI Bridge A - 032C
                                            [Count] => 1
                                        )

                                    [20] => Array
                                        (
                                        )

                                    [20_attr] => Array
                                        (
                                            [Name] => Intel(R) 82801GB/GR (ICH7 Family) LPC Interface Controller - 27B8
                                            [Count] => 1
                                        )

                                    [21] => Array
                                        (
                                        )

                                    [21_attr] => Array
                                        (
                                            [Name] => Intel(R) 82801G (ICH7 Family) SMBus Controller - 27DA
                                            [Count] => 1
                                        )

                                )

                        )

                    [USB] => Array
                        (
                            [Device] => Array
                                (
                                )

                            [Device_attr] => Array
                                (
                                    [Name] => USB-hoofdhub
                                    [Count] => 5
                                )

                        )

                    [IDE] => Array
                        (
                            [Device] => Array
                                (
                                    [0] => Array
                                        (
                                        )

                                    [1] => Array
                                        (
                                        )

                                    [0_attr] => Array
                                        (
                                            [Name] => TSSTcorp DVD-ROM SH-D162D ATA Device
                                            [Count] => 1
                                        )

                                    [1_attr] => Array
                                        (
                                            [Name] => ST3500320NS ATA Device
                                            [Count] => 1
                                        )

                                )

                        )

                    [SCSI] => Array
                        (
                        )

                    [CPU] => Array
                        (
                            [CpuCore] => Array
                                (
                                    [0] => Array
                                        (
                                        )

                                    [1] => Array
                                        (
                                        )

                                    [0_attr] => Array
                                        (
                                            [Model] => Intel(R) Xeon(R) CPU           X3210  @ 2.13GHz
                                            [CpuSpeed] => 2128
                                            [BusSpeed] => 266
                                            [Cache] => 8388608
                                        )

                                    [1_attr] => Array
                                        (
                                            [Model] => Intel(R) Xeon(R) CPU           X3210  @ 2.13GHz
                                            [CpuSpeed] => 2128
                                            [BusSpeed] => 266
                                            [Cache] => 8388608
                                        )

                                    [2] => Array
                                        (
                                        )

                                    [2_attr] => Array
                                        (
                                            [Model] => Intel(R) Xeon(R) CPU           X3210  @ 2.13GHz
                                            [CpuSpeed] => 2128
                                            [BusSpeed] => 266
                                            [Cache] => 8388608
                                        )

                                    [3] => Array
                                        (
                                        )

                                    [3_attr] => Array
                                        (
                                            [Model] => Intel(R) Xeon(R) CPU           X3210  @ 2.13GHz
                                            [CpuSpeed] => 2128
                                            [BusSpeed] => 266
                                            [Cache] => 8388608
                                        )

                                )

                        )

                )

            [Memory] => Array
                (
                    [Details] => Array
                        (
                        )

                    [Swap] => Array
                        (
                            [Mount] => Array
                                (
                                )

                            [Mount_attr] => Array
                                (
                                    [MountPointID] => 1
                                    [FSType] => swap
                                    [Name] => SWAP
                                    [Free] => 1827667968
                                    [Used] => 315621376
                                    [Total] => 2143289344
                                    [Percent] => 15
                                    [MountPoint] => C:\pagefile.sys
                                )

                        )

                    [Swap_attr] => Array
                        (
                            [Free] => 1827667968
                            [Used] => 315621376
                            [Total] => 2143289344
                            [Percent] => 15
                        )

                )

            [Memory_attr] => Array
                (
                    [Free] => 1112080384
                    [Used] => 1031331840
                    [Total] => 2143412224
                    [Percent] => 49
                )

            [FileSystem] => Array
                (
                    [Mount] => Array
                        (
                            [0] => Array
                                (
                                )

                            [1] => Array
                                (
                                )

                            [0_attr] => Array
                                (
                                    [MountPointID] => 1
                                    [FSType] => 
                                    [Name] => Removable Disk (3 1/2 in.)
                                    [Free] => 0
                                    [Used] => 0
                                    [Total] => 0
                                    [Percent] => 0
                                    [MountPoint] => A:
                                )

                            [1_attr] => Array
                                (
                                    [MountPointID] => 2
                                    [FSType] => NTFS
                                    [Name] => Local Disk
                                    [Free] => 8995835904
                                    [Used] => 355159924736
                                    [Total] => 364155760640
                                    [Percent] => 98
                                    [MountPoint] => C:
                                )

                            [2] => Array
                                (
                                )

                            [2_attr] => Array
                                (
                                    [MountPointID] => 3
                                    [FSType] => 
                                    [Name] => Compact Disc
                                    [Free] => 0
                                    [Used] => 0
                                    [Total] => 0
                                    [Percent] => 0
                                    [MountPoint] => D:
                                )

                            [3] => Array
                                (
                                )

                            [3_attr] => Array
                                (
                                    [MountPointID] => 4
                                    [FSType] => NTFS
                                    [Name] => Local Disk
                                    [Free] => 95008272384
                                    [Used] => 16695476224
                                    [Total] => 111703748608
                                    [Percent] => 15
                                    [MountPoint] => E:
                                )

                            [4] => Array
                                (
                                )

                            [4_attr] => Array
                                (
                                    [MountPointID] => 5
                                    [FSType] => NTFS
                                    [Name] => Local Disk
                                    [Free] => 23183179776
                                    [Used] => 1061990400
                                    [Total] => 24245170176
                                    [Percent] => 5
                                    [MountPoint] => F:
                                )

                        )

                )

            [MBInfo] => Array
                (
                )

            [UPSInfo] => Array
                (
                )

            [Plugins] => Array
                (
                )

            [Errors] => Array
                (
                )

        )

    [tns:phpsysinfo_attr] => Array
        (
            [xmlns:tns] => http://phpsysinfo.sourceforge.net/
            [xmlns:xsi] => http://www.w3.org/2001/XMLSchema-instance
            [xsi:schemaLocation] => http://phpsysinfo.sourceforge.net/phpsysinfo3.xsd
        )

)


En nu is mijn bedoeling om van deze XML pagina (URL!) op een PHP pagina naar $array['key'] te gaan. Alleen ik heb geen idee hoe ik dat in elkaar moet fietsen.

Ik wil dus de CPU, Mounts, Memmory, SWAP, Vitals_attr en de Networks laten zien door middel van die $array['key'].

Kan iemand me op weg helpen?
Alvast bedankt!
Dit al in Google ingetypt: php xml to array?
Geeft je SimpleXML.

Maar ik neem aan dat je code-blok hierboven GEEN directe output (tekst) is van een URL.
Zo wel: kijk ook even naar str_split() etc.
Of makkelijker, maar dan moet je zeker weten wat je binnenkrijgt: [php]eval()[/php]

Direct van StackOverflow (2e hit op Google):

<?php
$whatever = "array('Test','Blah')";
$parsed = eval("return " . $whatever . ";");
echo $parsed[1]; //This will be "Blah"
?>

En in $whatever kan je natuurlijk die tekst gooien via file_get_contents() of iets dergelijks.
Zo ziet de XML file eruit:


<tns:phpsysinfo xmlns:tns="http://phpsysinfo.sourceforge.net/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://phpsysinfo.sourceforge.net/phpsysinfo3.xsd">
<Generation version="3.1.2" timestamp="1362867376"/>
<Options tempFormat="c" byteFormat="auto_binary" refresh="60000" showPickListTemplate="true" showPickListLang="true"/>
<UsedPlugins/>
<Vitals Hostname="*hostname*" IPAddr="*ipadres*" Kernel="6.1.7600" Distro="Microsoft Windows 7 Ultimate" Distroicon="WinVista.png" Uptime="6512" Users="1" LoadAvg="1" SysLang="Dutch - Netherlands (1043)" CodePage="windows-1252"/>
<Network>
<NetDevice Name="Intel[R] PRO_1000 MT-netwerkverbinding" RxBytes="10877460" TxBytes="21518008" Err="0" Drops="0"/>
<NetDevice Name="Intel[R] PRO_1000 PM-netwerkverbinding" RxBytes="3938369" TxBytes="5517236" Err="0" Drops="3"/>
<NetDevice Name="Intel[R] PRO_1000 GT Desktop-adapter" RxBytes="0" TxBytes="0" Err="0" Drops="0"/>
<NetDevice Name="*dynamic*" RxBytes="0" TxBytes="0" Err="0" Drops="0"/>
<NetDevice Name="Teredo Tunneling Pseudo-Interface" RxBytes="912" TxBytes="748" Err="0" Drops="0"/>
</Network>
<Hardware>
<PCI>
<Device Name="Intel(R) PRO/1000 MT-netwerkverbinding" Count="1"/>
<Device Name="Intel(R) 82801GB/GR/GH (ICH7 Family) Serial ATA Storage Controller - 27C0" Count="1"/>
<Device Name="Intel(R) 82801G (ICH7 Family) Ultra ATA Storage Controllers - 27DF" Count="1"/>
<Device Name="Intel(R) PRO/1000 GT Desktop-adapter" Count="1"/>
<Device Name="Intel(R) 82801G (ICH7 Family) USB Universal Host Controller - 27C8" Count="1"/>
<Device Name="Intel(R) 82801GR/GH/GHM (ICH7 Family) PCI Express Root Port - 27E0" Count="1"/>
<Device Name="Intel(R) PRO/1000 PM-netwerkverbinding" Count="1"/>
<Device Name="Intel(R) 82801G (ICH7 Family) USB Universal Host Controller - 27C9" Count="1"/>
<Device Name="Intel(R) 82801GR/GH/GHM (ICH7 Family) PCI Express Root Port - 27E2" Count="1"/>
<Device Name="IPMI Interface" Count="1"/>
<Device Name="Intel(R) 82801G (ICH7 Family) USB Universal Host Controller - 27CA" Count="1"/>
<Device Name="PCI Serial Port" Count="1"/>
<Device Name="Intel(R) 82801G (ICH7 Family) USB Universal Host Controller - 27CB" Count="1"/>
<Device Name="Standaard-VGA grafische adapter" Count="1"/>
<Device Name="Intel(R) 82801 PCI Bridge - 244E" Count="1"/>
<Device Name="Intel(R) 82801G (ICH7 Family) USB2 Enhanced Host Controller - 27CC" Count="1"/>
<Device Name="Silicon Image SiI 3512 SATALink Controller" Count="1"/>
<Device Name="Intel(R) E7230/3000/3010 Processor to I/O Controller - 2778" Count="1"/>
<Device Name="Intel(R) 82801G (ICH7 Family) PCI Express Root Port - 27D0" Count="1"/>
<Device Name="Intel(R) 6702PXH PCI Express-to-PCI Bridge A - 032C" Count="1"/>
<Device Name="Intel(R) 82801GB/GR (ICH7 Family) LPC Interface Controller - 27B8" Count="1"/>
<Device Name="Intel(R) 82801G (ICH7 Family) SMBus Controller - 27DA" Count="1"/>
</PCI>
<USB>
<Device Name="USB-hoofdhub" Count="5"/>
</USB>
<IDE>
<Device Name="TSSTcorp DVD-ROM SH-D162D ATA Device" Count="1"/>
<Device Name="ST3500320NS ATA Device" Count="1"/>
</IDE>
<SCSI/>
<CPU>
<CpuCore Model="Intel(R) Xeon(R) CPU X3210 @ 2.13GHz" CpuSpeed="2128" BusSpeed="266" Cache="8388608"/>
<CpuCore Model="Intel(R) Xeon(R) CPU X3210 @ 2.13GHz" CpuSpeed="2128" BusSpeed="266" Cache="8388608"/>
<CpuCore Model="Intel(R) Xeon(R) CPU X3210 @ 2.13GHz" CpuSpeed="2128" BusSpeed="266" Cache="8388608"/>
<CpuCore Model="Intel(R) Xeon(R) CPU X3210 @ 2.13GHz" CpuSpeed="2128" BusSpeed="266" Cache="8388608"/>
</CPU>
</Hardware>
<Memory Free="1404940288" Used="738471936" Total="2143412224" Percent="35">
<Details/>
<Swap Free="1927282688" Used="216006656" Total="2143289344" Percent="11">
<Mount MountPointID="1" FSType="swap" Name="SWAP" Free="1927282688" Used="216006656" Total="2143289344" Percent="11" MountPoint="C:\pagefile.sys"/>
</Swap>
</Memory>
<FileSystem>
<Mount MountPointID="1" FSType="" Name="Removable Disk (3 1/2 in.)" Free="0" Used="0" Total="0" Percent="0" MountPoint="A:"/>
<Mount MountPointID="2" FSType="NTFS" Name="Local Disk" Free="8615305216" Used="355540455424" Total="364155760640" Percent="98" MountPoint="C:"/>
<Mount MountPointID="3" FSType="" Name="Compact Disc" Free="0" Used="0" Total="0" Percent="0" MountPoint="D:"/>
<Mount MountPointID="4" FSType="NTFS" Name="Local Disk" Free="95008272384" Used="16695476224" Total="111703748608" Percent="15" MountPoint="E:"/>
<Mount MountPointID="5" FSType="NTFS" Name="Local Disk" Free="23183179776" Used="1061990400" Total="24245170176" Percent="5" MountPoint="F:"/>
</FileSystem>
<MBInfo/>
<UPSInfo/>
<Plugins/>
<Errors/>
</tns:phpsysinfo>

Reageren