[ Поиск ] - [ Пользователи ] - [ Календарь ]
Полная Версия: PHP+XML
lilin
У меня вопрос к знающим людям, пишу страничку по прозьбе знакомых. В этом деле еще новичок, но работу надо сделать срочно! по этому своими силами не справлюсь

надо сделать чтото вроде новостной ленты, записи решила сохранять в xml файл
которые нужно вывести разумеется на страницу

пробовала так

PHP
foreach ($xml->msg as $msg) {
  echo 
'
<tr>
    <td><center>'
.$msg->name."</center></td>
    <td>"
;
  echo  
$msg->message."</td>
</tr>" 
;
}

но различный символы (русские буквы и всякие ö ä ü õ выводятся коряво (меняла кодировку- не помогло), в сам xml файл записывает все как надо

пробовала так


PHP
<?php

$XML 
= new DOMDocument(); 
$XML->load'data.xml' );  
 
$xslt = new XSLTProcessor(); 
$XSL = new DOMDocument(); 
$XSL->load'data.xsl'); 

$xslt->importStylesheet$XSL );  
print 
$xslt->transformToXML$XML );


выдает:

Warning: XSLTProcessor::importStylesheet() [xsltprocessor.importstylesheet]: compilation error: file file:///C:/wamp/www/haigla/data.xsl line 2 element stylesheet in C:\wamp\www\haigla\forum.php on line 12

Warning: XSLTProcessor::importStylesheet() [xsltprocessor.importstylesheet]: xsltParseStylesheetProcess : document is not a stylesheet in C:\wamp\www\haigla\forum.php on line 12

Warning: XSLTProcessor::transformToXml() [xsltprocessor.transformtoxml]: No stylesheet associated to this object in C:\wamp\www\haigla\forum.php on line 13

в гугле о том что это такое и как с этим бороться ничего вразумительного не нашла

вопрос: нужно чтоб пхп страничка красивенько все выводила. что сделать для этого?




Спустя 43 минуты, 22 секунды (20.07.2009 - 13:20) lilin написал(а):
вот еще на всякий случай

XML

Код
<?xml version="1.0" encoding="windows-1257"?>
<?xml-stylesheet type="text/xsl" href="data.xsl"?>
<forum>
   <msg>
       <name>Name1</name>
       <message>msg1</message>
   </msg>
   <msg>
       <name>Name2</name>
       <message>msg2</message>
   </msg>
</forum>


XSL

Код
<?xml version="1.0" encoding="WINDOWS-1257" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<table border="1">
   <tr bgcolor="#CCCCCC">
       <td align="center"><strong>Name</strong></td>
       <td align="center"><strong>Message</strong></td>
   </tr>
   <xsl:for-each select="forum/msg">
       <tr bgcolor="#F5F5F5">
           <td><xsl:value-of select="name"/></td>
           <td><xsl:value-of select="message"/></td>
       </tr>
   </xsl:for-each>
</table>
</xsl:template>
</xsl:stylesheet>


Спустя 42 минуты, 59 секунд (20.07.2009 - 14:03) Alecs написал(а):
Думаю utf-8 вам поможет.

Спустя 20 минут, 2 секунды (20.07.2009 - 14:23) Wird_34 написал(а):
lilin, windows-1257 - кодировка для балтийских языков, для кириллических используется windows-1251, но как заметил Alecs, используйте utf-8...

В data.xsl у вас ошибка, исправте вторую строку на:
HTML
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

Спустя 26 минут, 56 секунд (20.07.2009 - 14:50) lilin написал(а):
писала UTF8 не помогло

и мне и нужны для балтийских сейчас все öäüõ выводятся Ć¶Ć¤Ć¼

Спустя 10 минут, 52 секунды (20.07.2009 - 15:01) Wird_34 написал(а):
lilin, два вопроса:
1. В какой кодировке выводит браузер?
2. В какой кодировке сохранены файлы?

Спустя 4 месяца, 10 дней, 20 часов, 58 минут, 11 секунд (1.12.2009 - 12:59) Guest написал(а):
Добрый день!
Люди добрые помогите разобраться!!
При выполнении php :



<?php
/** @version $Id: class.xml_xsl.php,v 1.1.1.1 2008/08/20 04:40:26 cvsuser Exp $;
*/
class xml_xsl {
// $isdebug;
function setisdebug($isdebug=0){$this->isdebug=$isdebug;} //

function toxml($db,$sql=null,$filexsl=null,$arr=null ){
if (!empty($this->isdebug)) {
echo '123:$sql:'.$sql; echo "<pre>"; print_r($arr);echo"</pre>";
echo '123:$filexsl:'.$filexsl;
}
$res = $db->query($sql,$arr);
//if (DB::isError($res)) echo "<br>$sql<br>".$res->getMessage();
if (DB::isError($res)) throw new Exception("<br>$sql<br>".$res->getMessage());
if( $row = $res->fetchrow(DB_FETCHMODE_ASSOC)){
if (!empty($this->isdebug)) {
echo '<pre>VAL:';print_r($row['VAL']);echo'</pre>';
}
return self::transform($row['VAL'],$filexsl);
} else {
echo '$sql:'.$sql;
echo '$filexsl:'.$filexsl;
echo '<pre>arr:'; print_r($arr);echo'</pre>';
return self::transform('<TABLE></TABLE>',$filexsl);
}
//echo '$filexsl'.$filexsl;
//}
/*
$xml = new DOMDocument;
$xml->loadXML(iconv("windows-1251", "utf-8", $row['VAL']));
$xsl = new DOMDocument;
//$xsl->load("../template/admin/get.user.info.xsl");
$xsl->load($filexsl);
$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl);
return ($this->transform=$proc->transformToXML($xml));
*/
}
function toHTML($db,$sql=null,$filexsl=null,$arr=null ){
if (!empty($this->isdebug)) {
echo '$sql:'.$sql; echo "<pre>"; print_r($arr);echo"</pre>";
echo '$filexsl:'.$filexsl;
}
$res = $db->query($sql,$arr);
//if (DB::isError($res)) echo "<br>$sql<br>".$res->getMessage();
if (DB::isError($res)) throw new Exception("<br>$sql<br>".$res->getMessage());
if( $row = $res->fetchrow(DB_FETCHMODE_ASSOC)){
if (!empty($this->isdebug)) {
echo '<pre>VAL:';print_r($row['VAL']);echo'</pre>';
}
return str_replace('<?xml version="1.0" encoding="Windows-1251"?>','',self::transform($row['VAL'],$filexsl));
} else {
echo '$sql:'.$sql;
echo '$filexsl:'.$filexsl;
echo '<pre>arr:'; print_r($arr);echo'</pre>';
return self::transform('<TABLE></TABLE>',$filexsl);
}

}

function transformToXML($db,$sql=null, $xsl=null,$arr) {
//$this->setisdebug=1;
echo self::toxml($db,$sql, $xsl,$arr);
}
function transformToHTML($db,$sql=null, $xsl=null,$arr) {
//$this->setisdebug=1;
return self::toHTML($db,$sql, $xsl,$arr);
}
public function transform($val='<empty></empty>',$filexsl='',$in_charset='windows-1251',$out_charset='utf-8'){
// if (empty($val)) $val=' ';
$xml = new DOMDocument;
if ($in_charset<>$out_charset)
$xml->loadXML(iconv($in_charset,$out_charset, $val));
else
$xml->loadXML($val);
$xsl = new DOMDocument;
#
$xsl->load($filexsl);
//echo '<pre>';print_r($xsl);echo '</pre>';
$proc = new XSLTProcessor;
$proc->importStyleSheet($xsl);
#
return ($this->transform=$proc->transformToXML($xml));
#
}
} //end class
?>



отображаются следующие предупреждения:


Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: Undefined variable in C:\MWEB\HTDOCS\audit\class\class.xml_xsl.php on line 82

Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: compilation error: file file:///C%3A/MWEB/HTDOCS/audit/template/vat/table.cp.zb.xsl line 15 element IMG in C:\MWEB\HTDOCS\audit\class\class.xml_xsl.php on line 82

Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: Attribute template onclick: failed to compile $p_prep in C:\MWEB\HTDOCS\audit\class\class.xml_xsl.php on line 82

Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: Undefined variable in C:\MWEB\HTDOCS\audit\class\class.xml_xsl.php on line 82

Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: compilation error: file file:///C%3A/MWEB/HTDOCS/audit/template/vat/table.cp.zb.xsl line 23 element OPTION in C:\MWEB\HTDOCS\audit\class\class.xml_xsl.php on line 82

Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: Attribute template VALUE: failed to compile $p_id in C:\MWEB\HTDOCS\audit\class\class.xml_xsl.php on line 82

Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: Undefined variable in C:\MWEB\HTDOCS\audit\class\class.xml_xsl.php on line 82

Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: compilation error: file file:///C%3A/MWEB/HTDOCS/audit/template/vat/table.cp.zb.xsl line 28 element OPTION in C:\MWEB\HTDOCS\audit\class\class.xml_xsl.php on line 82

Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: Attribute template VALUE: failed to compile $p_id in C:\MWEB\HTDOCS\audit\class\class.xml_xsl.php on line 82

Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: Undefined variable in C:\MWEB\HTDOCS\audit\class\class.xml_xsl.php on line 82

Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: compilation error: file file:///C%3A/MWEB/HTDOCS/audit/template/vat/table.cp.zb.xsl line 36 element IMG in C:\MWEB\HTDOCS\audit\class\class.xml_xsl.php on line 82

Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: Attribute template onclick: failed to compile $p_next in C:\MWEB\HTDOCS\audit\class\class.xml_xsl.php on line 82

Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: Undefined variable in C:\MWEB\HTDOCS\audit\class\class.xml_xsl.php on line 82

Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: compilation error: file file:///C%3A/MWEB/HTDOCS/audit/template/vat/table.cp.zb.xsl line 72 element input in C:\MWEB\HTDOCS\audit\class\class.xml_xsl.php on line 82

Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: Attribute template value: failed to compile $cp_tin in C:\MWEB\HTDOCS\audit\class\class.xml_xsl.php on line 82

Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: Undefined variable in C:\MWEB\HTDOCS\audit\class\class.xml_xsl.php on line 82

Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: compilation error: file file:///C%3A/MWEB/HTDOCS/audit/template/vat/table.cp.zb.xsl line 74 element input in C:\MWEB\HTDOCS\audit\class\class.xml_xsl.php on line 82

Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: Attribute template value: failed to compile $cp_ipn in C:\MWEB\HTDOCS\audit\class\class.xml_xsl.php on line 82

Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: Undefined variable in C:\MWEB\HTDOCS\audit\class\class.xml_xsl.php on line 82

Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: compilation error: file file:///C%3A/MWEB/HTDOCS/audit/template/vat/table.cp.zb.xsl line 133 element input in C:\MWEB\HTDOCS\audit\class\class.xml_xsl.php on line 82

Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: Attribute template value: failed to compile $tzn in C:\MWEB\HTDOCS\audit\class\class.xml_xsl.php on line 82

Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: Undefined variable in C:\MWEB\HTDOCS\audit\class\class.xml_xsl.php on line 82

Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: compilation error: file file:///C%3A/MWEB/HTDOCS/audit/template/vat/table.cp.zb.xsl line 135 element input in C:\MWEB\HTDOCS\audit\class\class.xml_xsl.php on line 82

Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: Attribute template value: failed to compile $idd in C:\MWEB\HTDOCS\audit\class\class.xml_xsl.php on line 82

Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: Undefined variable in C:\MWEB\HTDOCS\audit\class\class.xml_xsl.php on line 82

Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: compilation error: file file:///C%3A/MWEB/HTDOCS/audit/template/vat/table.cp.zb.xsl line 136 element input in C:\MWEB\HTDOCS\audit\class\class.xml_xsl.php on line 82

Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: Attribute template value: failed to compile $cvat in C:\MWEB\HTDOCS\audit\class\class.xml_xsl.php on line 82

Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: Undefined variable in C:\MWEB\HTDOCS\audit\class\class.xml_xsl.php on line 82

Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: compilation error: file file:///C%3A/MWEB/HTDOCS/audit/template/vat/table.cp.zb.xsl line 137 element input in C:\MWEB\HTDOCS\audit\class\class.xml_xsl.php on line 82

Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: Attribute template value: failed to compile $cpf in C:\MWEB\HTDOCS\audit\class\class.xml_xsl.php on line 82

Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: Undefined variable in C:\MWEB\HTDOCS\audit\class\class.xml_xsl.php on line 82

Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: compilation error: file file:///C%3A/MWEB/HTDOCS/audit/template/vat/table.cp.zb.xsl line 138 element input in C:\MWEB\HTDOCS\audit\class\class.xml_xsl.php on line 82

Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: Attribute template value: failed to compile $d_end in C:\MWEB\HTDOCS\audit\class\class.xml_xsl.php on line 82

Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: Undefined variable in C:\MWEB\HTDOCS\audit\class\class.xml_xsl.php on line 82

Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: compilation error: file file:///C%3A/MWEB/HTDOCS/audit/template/vat/table.cp.zb.xsl line 139 element input in C:\MWEB\HTDOCS\audit\class\class.xml_xsl.php on line 82

Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: Attribute template value: failed to compile $zvt in C:\MWEB\HTDOCS\audit\class\class.xml_xsl.php on line 82

Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: Undefined variable in C:\MWEB\HTDOCS\audit\class\class.xml_xsl.php on line 82

Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: compilation error: file file:///C%3A/MWEB/HTDOCS/audit/template/vat/table.cp.zb.xsl line 140 element input in C:\MWEB\HTDOCS\audit\class\class.xml_xsl.php on line 82

Warning: XSLTProcessor::importStylesheet() [function.importStylesheet]: Attribute template value: failed to compile $id in C:\MWEB\HTDOCS\audit\class\class.xml_xsl.php on line 82

Warning: XSLTProcessor::transformToXml() [function.transformToXml]: No stylesheet associated to this object in C:\MWEB\HTDOCS\audit\class\class.xml_xsl.php on line 84



на екране отображаются только эти предупреждения....



Быстрый ответ:

 Графические смайлики |  Показывать подпись
Здесь расположена полная версия этой страницы.
Invision Power Board © 2001-2024 Invision Power Services, Inc.