ホームページ バックエンド開発 XML/RSS チュートリアル xml と xsl を使用して Web ページのサンプルを作成する

xml と xsl を使用して Web ページのサンプルを作成する

Feb 15, 2017 pm 03:58 PM
xm xsl

すべて、すべてのすべてのソースを示してください。 2 つのファイルを保存して実行するだけです。


cdcatalog.xmlはhtmlと同等です

cdcatalog.xslはcss


cdcatalog.xml

と同等です

[html] view plaincopy

<?xml version="1.0" encoding="ISO-8859-1"?> 
<?xml-stylesheet type="text/xsl" href="http://www.php1.cn/">
 
<catalog> 
  <cd> 
    <title>Empire Burlesque</title> 
    <artist>Bob Dylan</artist> 
    <country>USA</country> 
    <company>Columbia</company> 
    <price>10.90</price> 
    <year>1985</year> 
  </cd> 
 <cd> 
    <title>Empire Burlesqu2e</title> 
    <artist>Bob Dyla2n</artist> 
    <country>USA2</country> 
    <company>Columbia2</company> 
    <price>10.91</price> 
    <year>1983</year> 
  </cd> <cd> 
    <title>Empire Burlesqu2e</title> 
    <artist>Bob Dyla2n</artist> 
    <country>USA2</country> 
    <company>Columbia2</company> 
    <price>10.91</price> 
    <year>1983</year> 
  </cd> <cd> 
    <title>Empire Burlesqu2e</title> 
    <artist>Bob Dyla2n</artist> 
    <country>USA2</country> 
    <company>Columbia2</company> 
    <price>10.91</price> 
    <year>1983</year> 
  </cd> <cd> 
    <title>Empire Burlesqu2e</title> 
    <artist>Bob Dyla2n</artist> 
    <country>USA2</country> 
    <company>Columbia2</company> 
    <price>10.91</price> 
    <year>1983</year> 
  </cd> <cd> 
    <title>Empire Burlesqu2e</title> 
    <artist>Bob Dyla2n</artist> 
    <country>USA2</country> 
    <company>Columbia2</company> 
    <price>10.91</price> 
    <year>1983</year> 
  </cd> 
</catalog>



cdcatalog.xsl

[html] plaincopy を表示

<?xml version="1.0" encoding="ISO-8859-1"?> 
 
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
 
<xsl:template match="/"> 
  <html> 
  <body> 
    <h2>My CD Collection</h2> 
    <table border="1"> 
    <tr bgcolor="#9acd32"> 
      <th align="left">Title</th> 
      <th align="left">Artist</th> 
    </tr> 
    <xsl:for-each select="catalog/cd"> 
    <tr> 
      <td><xsl:value-of select="title"/></td> 
      <td><xsl:value-of select="artist"/></td> 
    </tr> 
    </xsl:for-each> 
    </table> 
  </body> 
  </html> 
</xsl:template> 
 
</xsl:stylesheet>



ブラウザで cdcatalog.xml を開いて効果を確認してください。ほとんどのブラウザとプログラミング言語でサポートされています。


効果:

私のCDコレクション

タイトル アーティストボブ・ディランボブ・ディラ2nボブ・ディラ2nボブ・ディラ2nボブ・ディラ2nボブ・ディラ2n上記は、xml と xsl を使用して Web ページのサンプルを作成する内容です。その他の関連コンテンツについては、PHP 中国語 Web サイト (m.sbmmt.com) に注目してください。
エンパイア・バーレスク
帝国バーレスク2e
帝国バーレスク2e
帝国バーレスク2e
帝国バーレスク2e
帝国バーレスク2e
このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。

ホットAIツール

Undress AI Tool

Undress AI Tool

脱衣画像を無料で

Undresser.AI Undress

Undresser.AI Undress

リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover

AI Clothes Remover

写真から衣服を削除するオンライン AI ツール。

Clothoff.io

Clothoff.io

AI衣類リムーバー

Video Face Swap

Video Face Swap

完全無料の AI 顔交換ツールを使用して、あらゆるビデオの顔を簡単に交換できます。

ホットツール

メモ帳++7.3.1

メモ帳++7.3.1

使いやすく無料のコードエディター

SublimeText3 中国語版

SublimeText3 中国語版

中国語版、とても使いやすい

ゼンドスタジオ 13.0.1

ゼンドスタジオ 13.0.1

強力な PHP 統合開発環境

ドリームウィーバー CS6

ドリームウィーバー CS6

ビジュアル Web 開発ツール

SublimeText3 Mac版

SublimeText3 Mac版

神レベルのコード編集ソフト(SublimeText3)

XMLスキーマ:PHPの例 XMLスキーマ:PHPの例 Jul 23, 2025 am 12:27 AM

xmlschemavalidationinphpisachieveveveveveveveveddomdocumentanddomxpathclassesseswiththelibxmlextension.1)loadthexmlfilewithdomdocument.2) useschemavalidatovalidateagain stanxsdssdssdsdssdssdssdscema、throwinganexceptionifvalidations.3)forlargefiles、usexmlreaderforstreamingva

外部RSSフィードをShopifyストアに統合する方法 外部RSSフィードをShopifyストアに統合する方法 Jul 24, 2025 am 02:13 AM

Integrateanexternalrssintososososososososososososososhopify、firstverifythefeed’svalidityandformatting.2.usecustomjavascriptwithapiLikerikerss2jsontofetheddisplaythefeedinaliquidtemplate、asshopifylacksnativeupport.3。

開発者向けのXMLの利点:シンプルさ、柔軟性、および移植性 開発者向けのXMLの利点:シンプルさ、柔軟性、および移植性 Jul 20, 2025 am 03:59 AM

xmlbenefitsdeveloperswithitssimplicity、柔軟性、およびポータビリティ。1)Human-readableformataidsineasydebugging.2)customizabletagsallowforadaptableastructures.3)プラットフォーム依存の依存性を維持する

XMLネームスペース:Webサービスのベストプラクティス XMLネームスペース:Webサービスのベストプラクティス Jul 14, 2025 am 12:03 AM

bestpracticesforusingxmlnamesspacesinwebserceare:1)usemevennamespaceuris、2)useshortanddescriptiveprefixes、3)一貫してアプリケーションスペース、4)避難所、5)ドキュメンタルスペース、および6)

よく形成されたXMLの執筆:初心者向けのステップバイステップガイド よく形成されたXMLの執筆:初心者向けのステップバイステップガイド Jul 13, 2025 am 12:23 AM

高度なxmliscrucialforensuringdocumentscanbeparesedandurstoundurstoodountood bynyxmlprocessor.tocreatewell-formedxml:1)useasinglerootelementashementasthefoundation、2)ensurealltagsareporperlyclosed、for foredtags forementyine、3)

XMLパフォーマンス:それは良い決断ですか? XMLパフォーマンス:それは良い決断ですか? Jul 15, 2025 am 01:07 AM

xml'suitability-forperformance-criticalapplicationsdependsonsusneeds.1)xml'sparsingoverheadcanbesificant、特にlargefiles.2)Serialization and dearization inxmlaretime-conuming.3)xml'sverbosityleadostessopargeLeargeLegerfilesizes、Impactingnetworkan

XML:よく形成されたXMLを検証しないとどうなりますか? XML:よく形成されたXMLを検証しないとどうなりますか? Jul 21, 2025 am 02:28 AM

notvalidatingwell-formedxmlcanleadtoseriousissues.1)dategegrityerrorsoccur withoutvalidation.2)InteroperabilityississeaSeassySeassyssmaystreptelly.3)セキュリティリスクの装備の継続的なエクスペリティなものbymaliousioutiatiotiationiousiousioty

XML書き込みルール:一般的なエラーを避けてください XML書き込みルール:一般的なエラーを避けてください Jul 21, 2025 am 01:50 AM

CommonXMLerrorsIncludeMismatchedTags、不正、Quotedattributevalues、CaseSensitivityIssues、InvalidCharacters、およびMisusedDeclarations.ToAvoidSeSE:1)usexmLeditorswithsaxhightinghightingingingingandauto-compopredismismismismismismismismismismatidtags.2)

See all articles