xml不显示css样式_如何使用CSS显示XML?
xml不顯示css樣式
Introduction:
介紹:
You must be aware of the term XML and must have dealt with these various XML files while developing a web page or website. This article focuses entirely on XML and how to display them using CSS. There are numerous steps to follow for displaying the XML using CSS, all those steps are discussed further in the article but before moving forward let us have a look at the definition and purpose of XML for a better understanding.
您必須了解術語XML,并且在開發網頁或網站時必須已經處理了這些各種XML文件。 本文完全側重于XML以及如何使用CSS顯示它們。 使用CSS顯示XML需要遵循許多步驟,本文將進一步討論所有這些步驟,但是在繼續進行之前,讓我們先了解一下XML的定義和目的,以更好地理解。
Definition:
定義:
XML stands for Extensible markup language. XML is designed to store and transport data. XML is designed in a way that it becomes readable by both humans and machines.
XML代表可擴展標記語言 。 XML旨在存儲和傳輸數據。 XML的設計使其可以被人類和機器讀取。
Now, after getting familiar with the definition and purpose of the XML, let us keep moving forward and have a look at the steps to display XML using CSS.
現在,在熟悉XML的定義和用途之后,讓我們繼續前進,看看使用CSS顯示XML的步驟。
Here we will discuss how to display XML using CSS but before that, why don't we go through the defining of the CSS first so that we can understand it more clearly.
在這里,我們將討論如何使用CSS顯示XML,但是在此之前,為什么不首先進行CSS的定義,以便我們可以更清楚地理解它。
CSS stands for Cascading Style Sheet. CSS can be used to add styles and to display information to an XML file in a clear and precise manner. It can format the whole XML document.
CSS代表層疊樣式表 。 CSS可用于添加樣式并以清晰,精確的方式將信息顯示到XML文件中。 它可以格式化整個XML文檔。
Steps for defining CSS for XML:
為XML定義CSS的步驟 :
For defining the CSS style sheets for XML documents following steps are to be followed,
要為XML文檔定義CSS樣式表,請遵循以下步驟,
- Define the styling for specific elements such as font size, font color, etc.
- Define each element as a list element, block using display property of CSS.
- Identify the titles and make them bold.
Linking XML with CSS:
將XML與CSS鏈接 :
To display an XML document with CSS, it is of utmost importance to link that XML document with CSS.
要使用CSS顯示XML文檔,最重要的是將XML文檔與CSS鏈接。
The syntax below can be used to link XML document to CSS.
以下語法可用于將XML文檔鏈接到CSS。
<?xml-stylesheet type="text/css" href = "name_of_the_CSSFile.css"?>
Note:
注意:
Make sure that the above syntax is used on top of the XML file otherwise the XML will not be displayed and you might run into some errors.
確保在XML文件頂部使用上述語法,否則XML將不會顯示,并且您可能會遇到一些錯誤。
Example:
例:
To understand a concept clearly, an example plays a very important role therefore an example is curated just for you that would help in making things much more clear. In this example, the XML file is created that contains the information about five subjects and displaying the XML file using CSS.
為了清楚地理解一個概念,一個示例起著非常重要的作用,因此為您精心策劃一個示例,這將有助于使事情變得更加清晰。 在此示例中,將創建XML文件,其中包含有關五個主題的信息,并使用CSS顯示XML文件。
XML File:
XML檔案:
Creating "Class.xml" as XML file
創建“ Class.xml”作為XML文件
<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/css" href="Semester.css"?> <subject> <heading>Welcome To IncludeHelp</heading> <subject> <name>Name -: Compiler Design</name> <teacher>Teacher -: Chris</teacher> <credits>Credits -: 3.0</credits> </subject> <subject> <name>Name -: Software Engineering</name><teacher>Teacher -: S.K Jha</teacher> <credits>Credits -: 2.0</credits> </subject> <subject> <name>Name -: Operating System</name> <teacher>Teacher -: Sanjay</teacher> <credits>Credits -: 3.0</credits> </subject> <subject> <name>Name -: DBMS</name><teacher>Teacher -: Aman Singh</teacher> <credits>Credits -: 4.0</credits> </subject> <subject> <name>Name -: Data Science</name><teacher>Teacher -: Hitendra Dhakarey</teacher> <credits>Credits -: 1.0</credits> </subject> </subject>CSS File:
CSS文件:
Creating "Semester.css" as CSS file,
創建“ Semester.css”作為CSS文件,
subject {color: white;background-color: red;width: 100%; }heading {color: green;font-size: 40px;background-color: pink; }heading, name, teacher, credits {display: block; }name {font-size: 25px;font-weight: bold; }Output:
輸出:
In the above example, you can see that an XML file is created that contains various information about subjects and their corresponding teachers and after that displaying the XML file using CSS.
在上面的示例中,您可以看到創建了一個XML文件,其中包含有關主題及其相應教師的各種信息,然后使用CSS顯示XML文件。
Now that you are aware of how to display your XML files using CSS why don't you go ahead and try it yourself?
既然您已經知道如何使用CSS顯示XML文件,為什么不繼續自己嘗試一下呢?
翻譯自: https://www.includehelp.com/code-snippets/how-to-display-xml-using-css.aspx
xml不顯示css樣式
總結
以上是生活随笔為你收集整理的xml不显示css样式_如何使用CSS显示XML?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java double方法_Java D
- 下一篇: 数据库范式5nf_第四范式(4NF)|