使用 css 显示 xml,如何使用CSS 显示 XML

使用CSS显示XML的方法:首先打开相应的代码文件;然后通过“<?xml-stylesheet type="text/css" href="cd_catalog.css"?>”方法把XML文件链接到CSS文件即可。

9e0d79a07c7d3a7fd653e2afe93baab1.png

使用 CSS 显示 XML

通过使用 CSS,可为 XML 文档添加显示信息。

使用 CSS 显示您的 XML?

使用 CSS 来格式化 XML 文档是有可能的。

下面的例子就是关于如何使用 CSS 样式表来格式化 XML 文档:

这是 XML 文件:CD 目录This XML file does not appear to have any style information associated with it. The document tree is shown below.

Empire Burlesque

Bob Dylan

USA

Columbia

10.90

1985

Hide your heart

Bonnie Tyler

UK

CBS Records

9.90

1988

Greatest Hits

Dolly Parton

USA

RCA

9.90

1982

Still got the blues

Gary Moore

UK

Virgin records

10.20

1990

Eros

Eros Ramazzotti

EU

BMG

9.90

1997

One night only

Bee Gees

UK

Polydor

10.90

1998

Sylvias Mother

Dr.Hook

UK

CBS

8.10

1973

Maggie May

Rod Stewart

UK

Pickwick

8.50

1990

Romanza

Andrea Bocelli

EU

Polydor

10.80

1996

When a man loves a woman

Percy Sledge

USA

Atlantic

8.70

1987

Black angel

Savage Rose

EU

Mega

10.90

1995

1999 Grammy Nominees

Many

USA

Grammy

10.20

1999

For the good times

Kenny Rogers

UK

Mucik Master

8.70

1995

Big Willie style

Will Smith

USA

Columbia

9.90

1997

Tupelo Honey

Van Morrison

UK

Polydor

8.20

1971

The very best of

Cat Stevens

UK

Island

8.90

1990

Stop

Sam Brown

UK

A and M

8.90

1988

Bridge of Spies

T'Pau

UK

Siren

7.90

1987

Private Dancer

Tina Turner

UK

Capitol

8.90

1983

Midt om natten

Kim Larsen

EU

Medley

7.80

1983

Pavarotti Gala Concert

Luciano Pavarotti

UK

DECCA

9.90

1991

The dock of the bay

Otis Redding

USA

Atlantic

7.90

1987

Picture book

Simply Red

EU

Elektra

7.20

1985

Red

The Communards

UK

London

7.80

1987

Unchain my heart

Joe Cocker

USA

EMI

8.20

1987

这是样式表:CSS 文件CATALOG

{

background-color: #ffffff;

width: 100%;

}

CD

{

display: block;

margin-bottom: 30pt;

margin-left: 0;

}

TITLE

{

color: #FF0000;

font-size: 20pt;

}

ARTIST

{

color: #0000FF;

font-size: 20pt;

}

COUNTRY,PRICE,YEAR,COMPANY

{

display: block;

color: #000000;

margin-left: 20pt;

}

最后,请查看效果:由 CSS 文件格式化的 CD 目录

下面是此XML文件的一个片断。 第二行,<?xml-stylesheet type="text/css" href="cd_catalog.css"?>,把这个 XML 文件链接到 CSS 文件:<?xml version="1.0" encoding="ISO-8859-1"?>

Empire Burlesque

Bob Dylan

USA

Columbia

10.90

1985

Hide your heart

Bonnie Tyler

UK

CBS Records

9.90

1988

.

.

.

.

注释:使用 CSS 格式化 XML 不是常用的方法,更不能代表 XML 文档样式化的未来。W3C 推荐使用 XSLT。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值