Dize DOMElement dönüştürmek ve sonra istenmeyen etiketleri şerit

0 Cevap php

Şimdi, topluluk sayesinde, bir sorun giderilmiştir (Delete all elements of a certain type from an XML doc using PHP). Şimdi neyse ki başka :) vurdu

Yani, XML dosyası vardır:

<piletilve_info>
   <shows>
      <show>
        <description>
          <lat>
        <![CDATA[ 
LA CENERENTOLA  <BR><BR>

("Cinderella")<BR><BR>

Opera buffo by Gioachino Rossini<BR><BR>


Music Director and Conductor: Arvo Volmer<BR>
Stage Director and Set Designer: Michiel Dijkema (Amsterdam)<BR>
Costumes: Claudia Damm (Berlin)<BR><BR>



Premiere on November 10, 2006<BR>
Approx running time: 3 h 20 min<BR>
Sung in Italian with subtitles in Estonian and English<BR><BR>

Who hasn’t heard the fairy-tale of Cinderella who crouched in the ashes, danced to the tune of her step-sisters but finally found the man of her dreams and a happy life. Why should this fairy-tale be told today?<BR>
An exciting and unexpected solution of the story of Cinderella with striking scenery and fantastic-modern costumes is presented by the Dutch stage director Michiel Dijkema and the German designer Claudia Damm.<BR>
In this story, an unhappy soul dreams of a prince on a white horse and of a better life, and women following the last trends chase the prince, and a man who considers himself very wise, is only interested in himself.<BR>
"Cinderella" is not just a fairy-tale, it includes reality as well as dreams, a lot of fantasies, comedy and grotesque. And all of this is expressed by the brilliant and virtuous music of Rossini!<BR>

  ]]> 
          </lat>
        </description>
      </show>
   </shows>
   <other node>
      ...
   </other node>
</piletilve_info>

Ben bu kodu kullanarak benim ihtiyaç düğüme gidin:

$books = $xpath->query('shows/show/description');
        foreach($books as $description)
        {
            $description->removeChild($eng_lang);
            $lat_lang = $description->getElementsByTagName('lat')->item(0);
            }

: I $lat_lang elemanları, bir <[[CDATA ]]> ebeveyn, bu karma işlevi kullanarak içeriği değiştirilmiş çıkış istiyor

$lat_lang->nodeValue = mb_convert_encoding(print_r(strip_tags_only($lat_lang->item(0)->nodeValue, TRUE),'<html><head><body>'), 'UTF-8' ,$encoding);

, Ama ben ve başarısız ben apache sunucu üzerinde komut dosyası çalıştırdığınızda, bu hatayı alıyorum:

The XML page cannot be displayed Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.


Only one top level element is allowed in an XML document. Error processing resource 'http://www.bilesuserviss.lv/lv_filtrs_...

Catchable fatal error: Object of class DOMElement could not be converted to string in /var/www/...

Bana çözüm bulmak yardımcı olabilir mi?

Belki delphi geliştirmek yapmak aslında bana bütün bu PHP yapar <-> XML daha zor kodlama normal insanlar için olur ..: (

0 Cevap