Buongiorno a tutti, ho questo file xml:
e questo file php:
Ma mi interpreta male gli accenti. Come posso fare? Ho provato anche in UTF8 ma la situazione non migliora.
Ci sono delle funzioni (tipo htmlentities) che risolvono il problema? se si, come?
grazie
Martino[/CODE]
Codice:
<?xml version="1.0" encoding="iso-8859-1"?>
<MENU>
<word><it>bontà </it><en>goodness</en></word>
</MENU>
e questo file php:
PHP:
<html>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<?PHP header('Content-type: text/html; charset=iso-8859-1'); ?>
<head>
<style>
body {
font-family: "Times New Roman OS";
font-weight: 100;
font-size:24px;
background-color:#333;
text-align:center;
}
input {
padding:5px;
background-color:#222;
color:#bbb;
border:0;
font-style: italic;
margin:6px 0;
height:30px;
}
</style>
</head>
<body>
<?PHP
$documento = new DOMDocument();
$documento->load( 'file.xml' );
$elementi = $documento->getElementsByTagName( "word" );
$num=0;
$wordit = array();
foreach( $elementi as $elemento ){
$num=$num+1;
$nomelemento = $elemento->getElementsByTagName( "it" );
$wordit[$num] = $nomelemento->item(0)->nodeValue;
$nomelemento = $elemento->getElementsByTagName( "en" );
$worden[$num] = $nomelemento->item(0)->nodeValue;
}
$randomlingua = rand(1,2);
$randomword = rand(1,$num);
?>
<div style="border:2px dashed #999; padding:10px; width:400px; margin:200px auto 0 auto;">
<?PHP if ($randomlingua == 1) { ?>
<span style="color:#fff; font-style: italic;"><?PHP echo $wordit[$randomword];?> (ita)</span><br><input type="text" size="50" placeholder="write text">
<span style="color:#333;"><?PHP echo $worden[$randomword];?></span><br>
<?PHP } else { ?>
<span style="color:#007bba; font-style: italic;"><?PHP echo $worden[$randomword];?> (eng)</span><br><input type="text" size="50" placeholder="write text">
<span style="color:#333;"><?PHP echo $wordit[$randomword];?></span><br>
<?PHP } ?>
</div>
</body>
</html>
Ma mi interpreta male gli accenti. Come posso fare? Ho provato anche in UTF8 ma la situazione non migliora.
Ci sono delle funzioni (tipo htmlentities) che risolvono il problema? se si, come?
grazie
Martino[/CODE]
Ultima modifica di un moderatore: