使用google插件高亮显示xml

这篇博客介绍了如何利用google插件SyntaxHighlighter的1.5.1版本来高亮显示XML代码。通过引入相应的CSS和JS文件,然后设置HTML预格式化标签`<pre>`,并指定class为'xml',最后调用`dp.SyntaxHighlighter.HighlightAll('response')`方法来高亮显示id为'response'的内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

引入google插件js,这里使用的是version1.5.1,至于为什么没有使用最新版version3.0.8已经忘记了

<!--SyntaxHighlighter-->
    <link href="../../js/SyntaxHighlighter_1.5.1/styles/SyntaxHighlighter.css" rel="stylesheet" type="text/css"/>
    <script src="../../js/SyntaxHighlighter_1.5.1/scripts/shCore.js" language="javascript"></script>
    <script src="../../js/SyntaxHighlighter_1.5.1/scripts/shBrushXml.js" language="javascript"></script>

 

html如此:

<pre name="response" id="response" class="xml">

<?xml version="1.0" encoding="utf-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap /envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001 /XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><SOAP-ENV:Body><m:CheckReservations xmlns:m="http://webservices.hotel.de/MyRES/V1_1"><m:objRequest><m:WebServiceConsumerID>110</m:WebServiceConsumerID ><m:WebServiceConsumerPassword>!c4r75n)/</m:WebServiceConsumerPassword><m:Token>123456</m:Token><m:Reservation_StartDateTime >2011-02-28T00:00:00.0Z</m:Reservation_StartDateTime><m:Reservation_EndDateTime>2011-03-01T23:59:59.59Z </m:Reservation_EndDateTime><m:PropertyNumbers><m:int>126621</m:int></m:PropertyNumbers><m:ReservationSearchMethod >ByReservationDate</m:ReservationSearchMethod></m:objRequest></m:CheckReservations></SOAP-ENV:Body>< /SOAP-ENV:Envelope>

</pre>

调用高亮显示 name="response" 的内容(此处一定是name)

dp.SyntaxHighlighter.HighlightAll('response');

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值