Simple XML tutorial

Source: Internet
Author: User
Tags xsl xsl file

Simple XML document
//-------------------------------
To use XML to display normalized HTML text blocks, you must use the HTML basics.

Write a simple XML file, similar to the following.

<? XML version = "1.0" encoding = "gb2312"?>
<Doc>
</DOC>

This is the simplest XML file.
The first line of version indicates the XML version, and encoding indicates the encoding used.
Of course we Chinese must use Chinese characters. gb2312 is the meaning of Simplified Chinese.
Doc is our custom root tag. Each XML file must have a unique root tag.

But its name can be arbitrary, that is, you can use any name you like, not necessarily not
Doc.

However, XML files are not enough. You must use the XSL file to display them as HTML files or
Program to display as other text blocks.

To reference the XSL text block for formatting the XML file, you must add the following text to the original XML text block.
<? XML-stylesheet type = "text/XSL" href = "common. XSL"?>
This is the final XML document.
[Code]
<? XML version = "1.0" encoding = "gb2312"?>
<? XML-stylesheet type = "text/XSL" href = "common. XSL"?>
<Doc>
</DOC>
[/Code]
Common. XSL is the XSL document we need to write. You can fully regard it as a scalable
Css html text block.

So how to write the XSL text block?
This is probably the case.
<? XML version = "1.0" encoding = "gb2312"?>
<Html xsl: version = "1.0"

Xmlns: XSL = "http://www.w3.org/1999/XSL/Transform"

Xmlns = "http://www.w3.org/TR/xhtml1/strict">
</Html>
Friends who are familiar with HTML will soon know that we can create HTML tags.
How can we reference XML data?
Basically, it is implemented through such characters:
<XSL: For-each select = "Doc">
</XSL: For-each>

<Embed>
<XSL: attribute name = "src"> <XSL: value-of select = "MUS"/> </XSL: attribute>
</Embed>
//---------------------------------------
<XSL: value-of select = "xml tag"/> This sentence can be used to reference data between tags in XML.
<Embed> </embed> is the original HTML Tag, similar to <marquee>
<P> <B> <I> <Object> <Table>.
To reference attributes in HTML tags, you can use
<XSL: attribute name = "HTML Tag attribute"> </XSL: attribute>.
In this way, we can process most simple tasks of converting XML into HTML.

of course, if you are a Program member, you can implement automatic conversion.
1. Read the XML file
2. Check the XML version and encoding, and check whether the root contains? Several rows are followed by
root.
3. format the XML file based on the referenced XSL file or internal XSL and save it in another storage area
4. formatting method: Replace the data in XML with
replace
5. output.
although the whole process is roughly divided into five steps, the implementation is far more than five steps.
There are many tools for formatting HTML Doc pdf on the Internet.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.