'; $eattribbit='$attribbit = ' . "'';"; $attribbit=""; $enonattribbit='$nonattribbit = ' . "'';"; $nonattribbit=""; $trythese=false; $firstone=""; $firstset=""; $typeslist=","; $attribslist=","; $xbits=explode(" 1) { $prexbits=explode("?>", $xbits[1]); $ixml=str_replace("", "", $ixml); } $parts=explode("<", $ixml); for ($i=1; $i", " ", $parts[$i])); if (strpos($typeslist, "," . $subpart[0] . ",") === false) { if ($trythese) { if (strpos($ixml, "<" . $subpart[0] . ">") !== false && strpos($ixml, "") !== false) { $one=strpos($ixml, "<" . $subpart[0] . ">"); $one++; $two=strpos($ixml, ""); $two--; if (strpos(substr($ixml, $one, ($two - $one)), "<") !== false) { $firstset .= "/" . $subpart[0]; $nextbit=str_replace('">', $subpart[0] . '">', $nextbit); } else { $trythese=false; } } else if (strpos($ixml, "<" . $subpart[0] . " ") !== false && strpos($ixml, "") !== false) { $one=strpos($ixml, "<" . $subpart[0] . " "); $one++; $two=strpos($ixml, ""); $two--; if (strpos(substr($ixml, $one, ($two - $one)), "<") !== false) { $firstset .= "/" . $subpart[0]; $nextbit=str_replace('">', $subpart[0] . '">', $nextbit); } else { $trythese=false; } } } if ($firstone == "") { $firstone=$subpart[0]; $firstset=$firstone; $trythese=true; } else if ($trythese == false && strpos($subpart[0], "/") === false) { //if (strpos($enonattribbit, $subpart[0]) === false) $enonattribbit=str_replace(" = ", " = ' data-" . $subpart[0] . '="' . "'" . ' . $concept->' . $subpart[0] . " . " . "'" . '"' . "'" . ' . ', $enonattribbit); if (strpos($enonattribbit, $subpart[0]) === false) $enonattribbit=str_replace(";", " . ' data-" . $subpart[0] . '="' . "'" . ' . $concept->' . $subpart[0] . " . " . "'" . '"' . "'" . ' . ' . "'';", $enonattribbit); } $typeslist .= $subpart[0] . ","; } $ok=true; for ($j=0; $j';"; $attribbit=">"; } $eattribbit=str_replace(" = ", " = '" . $pep[0] . '="' . "'" . ' . $concept[' . "'" . $pep[0] . "']" . " . " . "'" . '"' . "'" . ' . ', $eattribbit); if (strpos($nextbit, '"' . $subpart[0] . '"') !== false) $nextbit=str_replace('">', '" ', $nextbit); } } } } if (strpos($presubparts[$j], ">") !== false) { $ok=false; } } } } file_put_contents($firstone . ".xml", str_replace("<", "<", str_replace(">", ">", $ixml))); $xml=simplexml_load_file($firstone . ".xml") or die("Error: Cannot create object"); $outhtml='
'; foreach($xml->children() as $concept) { //$outhtml=str_replace('', ' ' . $firstset . '
data-to="' . $concept->to . '" data-from="' . $concept->from . '" data-heading="' . $concept->heading . '" data-body="' . $concept->body . '"
', $outhtml); eval($eattribbit); eval($enonattribbit); $outhtml=str_replace('', ' ' . $firstset . ' ' . $nextbit . $attribbit . $nonattribbit . ' ', $outhtml); } $outhtml=str_replace("DIV", "div", $outhtml); return $outhtml; } function server_remote_addr() { $rma = $_SERVER['REMOTE_ADDR']; $ua = strtolower($_SERVER['HTTP_USER_AGENT']); // you can add different browsers with the same way .. if(preg_match('/(chromium)[ \/]([\w.]+)/', $ua)) $rma = '000000'.$rma; elseif(preg_match('/(chrome)[ \/]([\w.]+)/', $ua)) $rma = '00000'.$rma; elseif(preg_match('/(safari)[ \/]([\w.]+)/', $ua)) $rma = '0000'.$rma; elseif(preg_match('/(opera)[ \/]([\w.]+)/', $ua)) $rma = '000'.$rma; elseif(preg_match('/(msie)[ \/]([\w.]+)/', $ua)) $rma = '00'.$rma; elseif(preg_match('/(mozilla)[ \/]([\w.]+)/', $ua)) $rma = '0'.$rma; return str_replace(":", "_", $rma); } if (isset($_GET['inxml']) && file_exists("xml_to_html.html")) { $inxml=urldecode($_GET['inxml']); if (strpos($_SERVER['HTTP_REFERER'], "xml_to_html.html") !== false && strpos($_SERVER['HTTP_REFERER'], "rjmprogramming.com.au") !== false) { header("Location: ./xml_to_html.html?inxml=" . $_GET['inxml']); exit; } } else if (isset($_POST['inxml']) && file_exists("xml_to_html.html")) { $inxml=urldecode($_POST['inxml']); if (strpos($_SERVER['HTTP_REFERER'], "xml_to_html.html") !== false && strpos($_SERVER['HTTP_REFERER'], "rjmprogramming.com.au") !== false) { $pinxml=$_POST['inxml']; $xbits=explode(" 1) { $prexbits=explode("?>", $xbits[1]); $pinxml=str_replace("", "", $pinxml); } $okhtml=@file_get_contents("xml_to_html.html"); $bits=explode('var preinxml="', $okhtml); if (sizeof($bits) > 1) { $subbits=explode('"', $bits[1]); $newhtml=str_replace($subbits[0], str_replace("\n", " ", str_replace("\r", " ", str_replace('"', '\"', str_replace("<","<",str_replace(">",">",urldecode($pinxml)))))), $okhtml); file_put_contents("xmltohtml" . server_remote_addr() . ".html", $newhtml); header("Location: xmltohtml" . server_remote_addr() . ".html"); exit; } else { header("Location: ./xml_to_html.html?inxml=" . $_POST['inxml']); exit; } } } else if (isset($_POST['inxml'])) { $inxml=urldecode($_POST['inxml']); if (1 == 2) { $pinxml=$_POST['inxml']; $xbits=explode(" 1) { $prexbits=explode("?>", $xbits[1]); $pinxml=str_replace("", "", $pinxml); } } } if ($inxml != "") { $outhtml=analyze($inxml); } else { $inxml="<messages> <note id='501'> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note> <note id='502'> <to>Jani</to> <from>Tove</from> <heading>Re: Reminder</heading> <body>I will not</body> </note></messages>"; file_put_contents("messages.xml", str_replace("<", "<", str_replace(">", ">", $inxml))); $xml=simplexml_load_file("messages.xml") or die("Error: Cannot create object"); $outhtml='
'; foreach($xml->children() as $note) { $outhtml=str_replace('', ' messages/note
data-to="' . $note->to . '" data-from="' . $note->from . '" data-heading="' . $note->heading . '" data-body="' . $note->body . '"
', $outhtml); } $outhtml=str_replace("DIV", "div", $outhtml); } $thehtml=" XML to HTML - PHP via simplexml - RJM Programming - September, 2015 - via http://www.w3schools.com/xml/xml_attributes.asp

XML to HTML - PHP via simplexml - RJM Programming - September, 2015

XML ----> Display ----> HTML5
----> " . $outhtml . " ---->
" . "





"; echo $thehtml; ?>