xml til træ struktur
Jeg skal ha udlæst en xml hvor den skal vise sig i træstruktur.hvis verdien ikke eksistere skal den vise èt billede og er verdien tilstæde skal den vise et andet billede.
ind til vidre har jeg følgendene men jeg kan ikke få den til at bygge træet korrekt.
Træet skulle gerne ende med at se sådan ud for denne xml
https://freeimage.host/i/HERw50X
<body>
<div class="box">
<ul class="directory-list">
<?php
$zip = new ZipArchive;
if ($zip->open('../../projects/0000000001/addon/eu_test/Tavle_test.padfx') === true) {
$xml_content = $zip->getFromName('DataSource.padf');
$xml = new SimpleXMLElement($xml_content);
echo "Region ID: " . $xml->Header->RegionId . "<br>";
echo "Child Region ID: " . $xml->Header->ChildRegionId . "<br>";
echo "File Creator: " . $xml->Header->FileCreator . "<br>";
echo "Assembly Version: " . $xml->Header->AssemblyVersion . "<br>";
echo "File Owner: " . $xml->Header->FileOwner . "<br>";
echo "Database Version: " . $xml->Header->DatabaseVersion . "<br>";
echo "Last Used Database Version: " . $xml->Header->LastUsedDatabaseVersion . "<br>";
echo "Last Saved Date: " . $xml->Header->LastSavedDate . "<br>";
foreach ($xml->Data->SO as $SO) {
if($SO->OID == 0) {
echo '<li class="node" alt="' . $SO->OID . ' title="' . $SO->OID . '">'. $SO->N . '';
if($SO->Ps->P) {
foreach ($SO->Ps->P as $P) {
echo ' - P ID: ' . $P['Id'] . ' V: ' . $P->V;
if ($P->GV) {
echo "<br>GVTy: " . $P->GV['GVTy'] . "<br>";
foreach ($P->GV->V as $V) {
echo "AtId: " . $V['AtId'] . " Value: " . $V . "<br>";
}
}
}
}
echo '<ul>';
} else if ($SO->OID == 1 || $SO->OID == 2) {
echo '<li class="object" alt="' . $SO->OID . ' title="' . $SO->OID . '">'. $SO->N . '';
if($SO->Ps->P) {
foreach ($SO->Ps->P as $P) {
echo ' - P ID: ' . $P['Id'] . ' V: ' . $P->V;
if ($P->GV) {
echo "<br>GVTy: " . $P->GV['GVTy'] . "<br>";
foreach ($P->GV->V as $V) {
echo "AtId: " . $V['AtId'] . " Value: " . $V . "<br>";
}
}
}
}
echo '<ul>';
} else {
echo "OID: " . $SO->OID . "<br>";
echo "N: " . $SO->N . "<br>";
}
foreach ($SO->Ms->M as $M) {
//echo "<br>M ID: " . $M['Id'] . "<br>";
echo "MID: " . $M->MID . "<br>";
echo "BID: " . $M->BID . "<br>";
foreach ($M->MPs->MP as $MP) {
echo "<br>MP ID: " . $MP['Id'] . "<br>";
echo "Value: " . $MP->V . "<br>";
}
foreach ($M->Ls->L as $L) {
echo "<br>L ID: " . $L['Id'] . "<br>";
echo "Value: " . $L->V . "<br>";
}
if($M->S = '5') {
$new_s = '<br><p style="color:red;">S: ' . $M->S . '</p><br>';
} else if($M->S = '1') {
$new_s = '<br><p style="color:green;">S: ' . $M->S . '</p><br>';
}
echo $new_s;
}
if ($SO->As) {
foreach ($SO->As->A as $A) {
echo "<br>A: " . $A . "<br>";
}
}
}
$zip->close();
}
?>
</div>
</body>
xml eksempel:
<?xml version="1.0" encoding="utf-8"?>
<Database Id="fb05">
<Header>
<RegionId>1000</RegionId>
<ChildRegionId>2</ChildRegionId>
<FileCreator>PC</FileCreator>
<AssemblyVersion>1.19.0.8076</AssemblyVersion>
<FileOwner>kodak</FileOwner>
<DatabaseVersion>-1--1</DatabaseVersion>
<LastUsedDatabaseVersion>-1--1</LastUsedDatabaseVersion>
<LastSavedDate>07.02.2023 17:45:32</LastSavedDate>
</Header>
<Data>
<SO Id="P8736ae982b4f40aca2d6d9e64f989f59">
<OID>0</OID>
<N>Node</N>
<PID>-1</PID>
<Ms />
</SO>
<SO Id="P63d414fdaf8c414ab2bcc82314e94eb1">
<N>45.1</N>
<PID>P8736ae982b4f40aca2d6d9e64f989f59</PID>
<OID>1</OID>
<Ms />
<Ps>
<P Id="65">
<V>45.1</V>
</P>
</Ps>
</SO>
<SO Id="P1aab4a4b96664cd5a8c579b85b55c775">
<OID>2</OID>
<N>Tavle Navn 1</N>
<PID>P63d414fdaf8c414ab2bcc82314e94eb1</PID>
<Ps>
<P Id="71">
<V>Tavle Navn 1</V>
</P>
<P Id="3">
<V>TN-S</V>
</P>
<P Id="72">
<V>Isolationtest BMS-KT.45.6A.-1.01</V>
</P>
</Ps>
<Ms>
<M Id="P7bd80659b03c44d4887695db676157a0">
<MID>4</MID>
<IGuIds>
<IGuId>21101825-20.04.2021-2.13.26-4.0-ALAM</IGuId>
</IGuIds>
<MPs>
<MP Id="1">
<V>07.01.2022 09:30:31</V>
</MP>
<MP Id="2">
<V>ALAM</V>
</MP>
<MP Id="3">
<V>2.13.26</V>
</MP>
<MP Id="4">
<V>500 V</V>
</MP>
<MP Id="11">
<V>-</V>
</MP>
</MPs>
<Ls>
<L Id="1">
<V>1 MOhm</V>
</L>
</Ls>
<Rs>
<R Id="9">
<V>>999MOhm</V>
<S>1</S>
</R>
<R Id="10">
<V>525V</V>
<S>0</S>
</R>
</Rs>
<S>1</S>
</M>
</Ms>
</SO>
<SO Id="Pdef14a1c6ecb490795743ed9c7a5c6bb">
<OID>9</OID>
<N>F1</N>
<PID>P1aab4a4b96664cd5a8c579b85b55c775</PID>
<Ps>
<P Id="96">
<V>F1</V>
</P>
<P Id="109">
<V>IEC/EN</V>
</P>
<P Id="111">
<V>100 A</V>
</P>
<P Id="110">
<V>10 A</V>
</P>
<P Id="105">
<V>0.4 s</V>
</P>
<P Id="108">
<V>C</V>
</P>
<P Id="114">
<V>30 mA</V>
</P>
<P Id="113">
<V>A</V>
</P>
<P Id="95">
<V>Kredsløb nr</V>
</P>
<P Id="97">
<V>Beskrivelse af kreds sikring</V>
</P>
<P Id="98">
<V>Kreds lokation</V>
</P>
<P Id="625" />
<P Id="103" />
<P Id="102" />
<P Id="100" />
<P Id="99" />
</Ps>
<Ms>
<M Id="Pe1c73a71b6f8426794f3a9755fc43001">
<MID>7</MID>
<IGuIds>
<IGuId>21101825-20.04.2021-2.13.26-4.0-ALAM</IGuId>
</IGuIds>
<MPs>
<MP Id="1">
<V>07.01.2022 09:41:28</V>
</MP>
<MP Id="2">
<V>ALAM</V>
</MP>
<MP Id="3">
<V>2.13.26</V>
</MP>
<MP Id="56">
<V>LPE</V>
</MP>
<MP Id="152">
<V>Rpe</V>
</MP>
<MP Id="338">
<V>standard</V>
</MP>
</MPs>
<Ls>
<L Id="3">
<V>2 Ohm</V>
</L>
</Ls>
<Rs>
<R Id="21">
<V>0.02Ohm</V>
<S>1</S>
</R>
<R Id="22">
<V>0.0Ohm</V>
<S>0</S>
</R>
<R Id="23">
<V>0.0Ohm</V>
<S>0</S>
</R>
<R Id="26">
<V>Yes</V>
<S>0</S>
</R>
</Rs>
<S>1</S>
</M>
<M Id="P6528dcb9c4c04ba68e508bf3fdd172cc">
<MID>14</MID>
<IGuIds>
<IGuId>21101825-20.04.2021-2.13.26-4.0-ALAM</IGuId>
</IGuIds>
<MPs>
<MP Id="1">
<V>07.01.2022 09:37:27</V>
</MP>
<MP Id="2">
<V>ALAM</V>
</MP>
<MP Id="3">
<V>2.13.26</V>
</MP>
<MP Id="131">
<V>fixed</V>
</MP>
<MP Id="20">
<V>AC</V>
</MP>
<MP Id="15">
<V>30 mA</V>
</MP>
<MP Id="233">
<V>-</V>
</MP>
<MP Id="14">
<V>EN 61008 / EN 61009</V>
</MP>
<MP Id="242">
<V>TN/TT</V>
</MP>
<MP Id="17">
<V>G</V>
</MP>
</MPs>
<Ls>
<L Id="6">
<V>50 V</V>
</L>
</Ls>
<Rs>
<R Id="116">
<V>24.6ms</V>
<S>0</S>
</R>
<R Id="117">
<V>33.4ms</V>
<S>0</S>
</R>
<R Id="120">
<V>6.0ms</V>
<S>0</S>
</R>
<R Id="121">
<V>11.8ms</V>
<S>0</S>
</R>
<R Id="122">
<V>>300ms</V>
<S>0</S>
</R>
<R Id="123">
<V>>300ms</V>
<S>0</S>
</R>
<R Id="124">
<V>22.5mA</V>
<S>0</S>
</R>
<R Id="125">
<V>24.0mA</V>
<S>0</S>
</R>
<R Id="114">
<V>0.1V</V>
<S>0</S>
</R>
</Rs>
<S>1</S>
</M>
<M Id="Pe931d0d28236473c98d6917e772dd95a">
<MID>14</MID>
<IGuIds>
<IGuId>21101825-20.04.2021-2.13.26-4.0-ALAM</IGuId>
</IGuIds>
<MPs>
<MP Id="1">
<V>07.01.2022 09:39:00</V>
</MP>
<MP Id="2">
<V>ALAM</V>
</MP>
<MP Id="3">
<V>2.13.26</V>
</MP>
<MP Id="131">
<V>fixed</V>
</MP>
<MP Id="20">
<V>A</V>
</MP>
<MP Id="15">
<V>30 mA</V>
</MP>
<MP Id="233">
<V>-</V>
</MP>
<MP Id="14">
<V>EN 61008 / EN 61009</V>
</MP>
<MP Id="242">
<V>TN/TT</V>
</MP>
<MP Id="17">
<V>G</V>
</MP>
</MPs>
<Ls>
<L Id="6">
<V>50 V</V>
</L>
</Ls>
<Rs>
<R Id="116">
<V>27.6ms</V>
<S>0</S>
</R>
<R Id="117">
<V>13.4ms</V>
<S>0</S>
</R>
<R Id="120">
<V>5.1ms</V>
<S>0</S>
</R>
<R Id="121">
<V>11.2ms</V>
<S>0</S>
</R>
<R Id="122">
<V>>300ms</V>
<S>0</S>
</R>
<R Id="123">
<V>>300ms</V>
<S>0</S>
</R>
<R Id="124">
<V>39.0mA</V>
<S>0</S>
</R>
<R Id="125">
<V>27.0mA</V>
<S>0</S>
</R>
<R Id="114">
<V>0.0V</V>
<S>0</S>
</R>
</Rs>
<S>1</S>
</M>
<M Id="Pe95c037ce6054bf29f593c7b51450eca">
<MID>2</MID>
<IGuIds>
<IGuId>21101825-20.04.2021-2.13.26-4.0-ALAM</IGuId>
</IGuIds>
<MPs>
<MP Id="1">
<V>07.01.2022 09:42:09</V>
</MP>
<MP Id="2">
<V>ALAM</V>
</MP>
<MP Id="3">
<V>2.13.26</V>
</MP>
<MP Id="230">
<V>1-phase</V>
</MP>
<MP Id="434">
<V>-</V>
</MP>
<MP Id="231">
<V>Voltage</V>
</MP>
<MP Id="242">
<V>TN/TT</V>
</MP>
<MP Id="436">
<V>Off</V>
</MP>
</MPs>
<Ls>
<L Id="97">
<V>207 V</V>
</L>
<L Id="98">
<V>253 V</V>
</L>
<L Id="101">
<V>207 V</V>
</L>
<L Id="102">
<V>253 V</V>
</L>
<L Id="103">
<V>0 V</V>
</L>
<L Id="104">
<V>10 V</V>
</L>
</Ls>
<Rs>
<R Id="1">
<V>237V</V>
<S>0</S>
</R>
<R Id="2">
<V>237V</V>
<S>0</S>
</R>
<R Id="3">
<V>0V</V>
<S>0</S>
</R>
<R Id="4">
<V>50.0Hz</V>
<S>0</S>
</R>
</Rs>
<S>1</S>
</M>
<M Id="Pd9ea820cde7b4e18935e493578d30c33">
<MID>17</MID>
<IGuIds>
<IGuId>21101825-20.04.2021-2.13.26-4.0-ALAM</IGuId>
</IGuIds>
<MPs>
<MP Id="1">
<V>07.01.2022 09:42:54</V>
</MP>
<MP Id="2">
<V>ALAM</V>
</MP>
<MP Id="3">
<V>2.13.26</V>
</MP>
<MP Id="108">
<V>C</V>
</MP>
<MP Id="28">
<V>10 A</V>
</MP>
<MP Id="29">
<V>0.1 s</V>
</MP>
<MP Id="31">
<V>1</V>
</MP>
<MP Id="235">
<V>-</V>
</MP>
<MP Id="242">
<V>TN/TT</V>
</MP>
</MPs>
<Ls>
<L Id="13">
<V>100 A</V>
</L>
</Ls>
<Rs>
<R Id="34">
<V>3.72kA</V>
<S>1</S>
</R>
<R Id="205">
<V>0.06Ohm</V>
<S>0</S>
</R>
<R Id="37">
<V>0.03Ohm</V>
<S>0</S>
</R>
<R Id="38">
<V>0.06Ohm</V>
<S>0</S>
</R>
<R Id="39">
<V>237V</V>
<S>0</S>
</R>
</Rs>
<S>1</S>
</M>
</Ms>
</SO>
<SO Id="Pf39c7fa412374063942a750fb782aca5">
<OID>2</OID>
<N>Tavle Navn 2</N>
<PID>P63d414fdaf8c414ab2bcc82314e94eb1</PID>
<Ps>
<P Id="71">
<V>Tavle Navn 2</V>
</P>
<P Id="3">
<V>TN-S</V>
</P>
<P Id="72">
<V>Isolationtest BMS-KT.45.6A.-1.01</V>
</P>
</Ps>
<Ms>
<M Id="P33b5ba5a01de477894b5ec64bba861e5">
<MID>4</MID>
<IGuIds />
<MPs>
<MP Id="1">
<V>07.01.2022 09:30:31</V>
</MP>
<MP Id="2">
<V>ALAM</V>
</MP>
<MP Id="3">
<V>2.13.26</V>
</MP>
<MP Id="4">
<V>500 V</V>
</MP>
<MP Id="11">
<V>-</V>
</MP>
</MPs>
<Ls>
<L Id="1">
<V>1 MOhm</V>
</L>
</Ls>
<Rs />
<S>5</S>
</M>
</Ms>
</SO>
<SO Id="Pa223cb2e6b864204a698c4bbf5c397a5">
<OID>9</OID>
<N>F1</N>
<PID>Pf39c7fa412374063942a750fb782aca5</PID>
<Ps>
<P Id="96">
<V>F1</V>
</P>
<P Id="109">
<V>IEC/EN</V>
</P>
<P Id="111">
<V>100 A</V>
</P>
<P Id="110">
<V>10 A</V>
</P>
<P Id="105">
<V>0.4 s</V>
</P>
<P Id="108">
<V>C</V>
</P>
<P Id="114">
<V>30 mA</V>
</P>
<P Id="113">
<V>A</V>
</P>
<P Id="95">
<V>Kredsløb nr</V>
</P>
<P Id="97">
<V>Beskrivelse af kreds sikring</V>
</P>
<P Id="98">
<V>Kreds lokation</V>
</P>
</Ps>
<Ms>
<M Id="P887aca482c74455d8ba836d8aa2227d7">
<MID>7</MID>
<IGuIds />
<MPs>
<MP Id="1">
<V>07.01.2022 09:41:28</V>
</MP>
<MP Id="2">
<V>ALAM</V>
</MP>
<MP Id="3">
<V>2.13.26</V>
</MP>
<MP Id="56">
<V>LPE</V>
</MP>
<MP Id="152">
<V>Rpe</V>
</MP>
<MP Id="338">
<V>standard</V>
</MP>
</MPs>
<Ls>
<L Id="3">
<V>2 Ohm</V>
</L>
</Ls>
<Rs />
<S>5</S>
</M>
<M Id="P6b617c0c7f174edd9f6e6ba5d109a227">
<MID>14</MID>
<IGuIds />
<MPs>
<MP Id="1">
<V>07.01.2022 09:37:27</V>
</MP>
<MP Id="2">
<V>ALAM</V>
</MP>
<MP Id="3">
<V>2.13.26</V>
</MP>
<MP Id="131">
<V>fixed</V>
</MP>
<MP Id="20">
<V>AC</V>
</MP>
<MP Id="15">
<V>30 mA</V>
</MP>
<MP Id="233">
<V>-</V>
</MP>
<MP Id="14">
<V>EN 61008 / EN 61009</V>
</MP>
<MP Id="242">
<V>TN/TT</V>
</MP>
<MP Id="17">
<V>G</V>
</MP>
</MPs>
<Ls>
<L Id="6">
<V>50 V</V>
</L>
</Ls>
<Rs />
<S>5</S>
</M>
<M Id="Pa85b10feaabb44c89de77669c1723762">
<MID>14</MID>
<IGuIds />
<MPs>
<MP Id="1">
<V>07.01.2022 09:39:00</V>
</MP>
<MP Id="2">
<V>ALAM</V>
</MP>
<MP Id="3">
<V>2.13.26</V>
</MP>
<MP Id="131">
<V>fixed</V>
</MP>
<MP Id="20">
<V>A</V>
</MP>
<MP Id="15">
<V>30 mA</V>
</MP>
<MP Id="233">
<V>-</V>
</MP>
<MP Id="14">
<V>EN 61008 / EN 61009</V>
</MP>
<MP Id="242">
<V>TN/TT</V>
</MP>
<MP Id="17">
<V>G</V>
</MP>
</MPs>
<Ls>
<L Id="6">
<V>50 V</V>
</L>
</Ls>
<Rs />
<S>5</S>
</M>
<M Id="P65d2c18f53a84fd9a20e282849821a90">
<MID>2</MID>
<IGuIds />
<MPs>
<MP Id="1">
<V>07.01.2022 09:42:09</V>
</MP>
<MP Id="2">
<V>ALAM</V>
</MP>
<MP Id="3">
<V>2.13.26</V>
</MP>
<MP Id="230">
<V>1-phase</V>
</MP>
<MP Id="434">
<V>-</V>
</MP>
<MP Id="231">
<V>Voltage</V>
</MP>
<MP Id="242">
<V>TN/TT</V>
</MP>
<MP Id="436">
<V>Off</V>
</MP>
</MPs>
<Ls>
<L Id="97">
<V>207 V</V>
</L>
<L Id="98">
<V>253 V</V>
</L>
<L Id="101">
<V>207 V</V>
</L>
<L Id="102">
<V>253 V</V>
</L>
<L Id="103">
<V>0 V</V>
</L>
<L Id="104">
<V>10 V</V>
</L>
</Ls>
<Rs />
<S>5</S>
</M>
<M Id="Paf889a4c35e74ae79023232f78b0d24f">
<MID>17</MID>
<IGuIds />
<MPs>
<MP Id="1">
<V>07.01.2022 09:42:54</V>
</MP>
<MP Id="2">
<V>ALAM</V>
</MP>
<MP Id="3">
<V>2.13.26</V>
</MP>
<MP Id="108">
<V>C</V>
</MP>
<MP Id="28">
<V>10 A</V>
</MP>
<MP Id="29">
<V>0.1 s</V>
</MP>
<MP Id="31">
<V>1</V>
</MP>
<MP Id="235">
<V>-</V>
</MP>
<MP Id="242">
<V>TN/TT</V>
</MP>
</MPs>
<Ls>
<L Id="13">
<V>100 A</V>
</L>
</Ls>
<Rs />
<S>5</S>
</M>
</Ms>
</SO>
</Data>
<Is>
<I>
<IGuId>21101825-20.04.2021-2.13.26-4.0-ALAM</IGuId>
<IHwV>4.0</IHwV>
<IMiNm>MI 3152</IMiNm>
<ISwV>2.13.26</ISwV>
<ISer>21101825</ISer>
<ICalD>20.04.2021</ICalD>
<IPCode>ALAM</IPCode>
</I>
<I>
<IGuId>21101825-20.04.2021-2.13.42-4.0-ALAM</IGuId>
<IHwV>4.0</IHwV>
<INm>EurotestXC</INm>
<IMiNm>MI 3152</IMiNm>
<ISwV>2.13.42</ISwV>
<ISer>21101825</ISer>
<ICalD>20.04.2021</ICalD>
<IPCode>ALAM</IPCode>
</I>
</Is>
<Us>
<U />
</Us>
</Database>