将文本解析为网页表条目? [英] Parsing text into web page table entries?
问题描述
我有一堆文件(媒体播放器的播放列表文件),我正在尝试
创建一个自动生成的网页,其中包含最后20或30
这些文件。文件每周创建一次,名为XX-XX-XX.ASX
其中X'代表日期即05-22-05.asx
文件是一种特定的格式,并且将始终包含以下
之类的标签:
< TITLE>我的媒体文件标题< / TITLE>
< AUTHOR>媒体文件作者< / AUTHOR>
< Ref href =" mms://media.mydomainname.com/2005/05-01-05.wma" />
我想解析这些文件中的标签,标题,作者,
和日期中的信息,然后将它们添加到网页上的表格中,但我没有运气
自己创建解析。任何人都可以用正确的方式给我一个良好的开端
方向使用vbscript来实现这一目标。
我特别难以将日期拉出来,因为它已经结束了
tag ..虽然我认为可以使用文件名,如果可以将
转换为格式正确的日期,即2005年5月1日
帮助?
您的输入文件似乎是XML格式。如果是这种情况,那么使用
MSXML解析器。不幸的是,我没有任何示例代码方便。但是如果
你的输入是XML让我们知道,我相信有人能够得到你开始的
。
-
Mark Schupp
"。:mmac:。 <丢失@海>在留言中写道
新闻:eo ************** @ TK2MSFTNGP15.phx.gbl ...我有一堆文件(媒体播放器的播放列表文件),我正在尝试
来创建一个自动生成的网页,其中包含最后20或30个这些文件。文件每周创建一次,名为
XX-XX-XX.ASX,其中X'代表日期,即05-22-05.asx
文件是特定的格式,并且总是包含以下
标签:
< TITLE>我的媒体文件标题< / TITLE>
< AUTHOR>媒体文件作者< / AUTHOR>
< Ref href = "彩信://media.mydomainname.com/2005/05-01-05.wma" />
我想解析这些文件中的标签,标题,作者,
和日期中的信息,然后将它们添加到网页上的表格中,但我没有
运气自己创建解析。任何人都可以使用vbscript在
正确的方向上给我一个良好的开端。
我特别难以将日期拉出来,因为它是在
标签的末尾。虽然我想可以使用文件名,如果可以将
转换为格式正确的日期,即2005年5月1日
帮助?
这是Windows媒体播放器的播放列表格式,MS说:
Advanced Stream Redirector(ASX)文件基于可扩展标记
语言(XML)语法" ;.
来自此页面
http://msdn.microsoft.com/library/de..._reference.asp
页面适用于winCE,但语法与我使用的相同。
同时我会查看MSXML Parser ...
谢谢
" Mark Schup P" <无**** @ nospam.com>在消息中写道
news:或************** @ TK2MSFTNGP14.phx.gbl ...您的输入文件似乎是XML格式。如果是这种情况,那么使用MSXML解析器。不幸的是,我没有任何示例代码方便。但是,如果您的输入是XML,请告诉我们,我相信有人能够>
你开始了。
-
标记Schupp
"。:mmac:。 <丢失@海>在消息中写道
新闻:eo ************** @ TK2MSFTNGP15.phx.gbl ...我有一堆文件(播放列表文件)对于媒体播放器而且我正在尝试
到创建一个自动生成的网页,其中包含最后20个或这些文件。文件每周创建一次,名为
XX-XX-XX.ASX其中X'代表日期,即05-22-05.asx <这些文件是一种特定的格式,并且将始终包含以下标签:
< TITLE>我的媒体文件标题< / TITLE>
< AUTHOR>媒体文件作者< / AUTHOR>
< Ref href =" mms://media.mydomainname.com/2005/05-01-05.wma" />
我想解析这些文件中的标签信息,标题,
作者,
和日期,然后将它们添加到网页上的表格中,但我有没有
运气自己创建解析。谁能给我一个良好的开端
对方向使用vbscript来实现这一目标。
我特别难以将日期拉出来,因为它是在
标签的结尾..虽然我认为如果可以
将转换为格式正确的日期,即可使用文件名,即2005年5月1日
帮助?
"。:mmac:。 <丢失@海>在留言中写道
新闻:eo ************** @ TK2MSFTNGP15.phx.gbl ...我有一堆文件(媒体播放器的播放列表文件),我正在尝试创建一个自动生成的网页,其中包含最后20个或这些文件。文件每周创建一次,名为
XX-XX-XX.ASX,其中X'代表日期,即05-22-05.asx
这些文件是特定的格式,并且总是包含以下
标签:
< TITLE>我的媒体文件标题< / TITLE>
< AUTHOR>媒体文件作者< / AUTHOR>
< Ref href = "彩信://media.mydomainname.com/2005/05-01-05.wma" />
我想解析这些文件中的标签,标题,作者,
和日期中的信息,然后将它们添加到网页上的表格中,但我没有
我特别难以将日期拉出来,因为它是在
标签的末尾。虽然我想如果可以将文件名转换为格式正确的日期,即2005年5月1日
帮助?
这里' '使用MSXML分析器的概念证明
[ShowASX.asp]
<%
CONST PATH =" << ASX DIRECTORY>>"
Dim xslt,xsl,proc,xml,fso,fld,fc,f
设置xsl = CreateObject(" MSXML2.FreeThreadedDOMDocument.4.0")
xsl.Load Server.MapPath(" asx2html.xsl")
设置xslt = CreateObject(" MSXML2.XSLTemplate.4.0 ")
设置xslt.stylesheet = xsl
设置proc = xslt.createProcessor()
设置xml = CreateObject(" MSXML2。 DOMDocument.4.0")
设置fso = CreateObject(" Scripting .FileSystemObject")
设置fld = fso.GetFolder(路径)
设置fc = fld.Files
Response.Write "&table; table border =''1''>"
For Each f in fc
如果正确(f.Name,4)="。 ASX"然后
xml.Load Server.MapPath(f.Name)
proc.input = xml
proc.Transform
Response.Write proc.output
结束如果
下一页
Response.Write"< / table>"
设置f =没有
设置fc =没什么
设置fld = Nothing
设置xml = Nothing
设置proc = Nothing
设置xslt = Nothing
设置xsl = Nothing
%>
[asx2html.xsl]
<?xml version =" 1.0" encoding =" utf-8"?>
< xsl:stylesheet version =" 1.0"
xmlns:xsl =" http:// www .w3.org / 1999 / XSL / Transform">
< xsl:output method =" html"版本= QUOT; 4.0" indent =" yes" />
< xsl:template match =" Asx">
< xsl:apply-templates select =" Entry" ; />
< / xsl:template>
< xsl:template match =" Entry">
< tr>
< td>< xsl:value-of select =" Title" />< / td>
< td>< xsl :value-of select =" Author" />< / td>
< td>
< xsl:call-template name =" String2Date" ;>
< xsl:with-param name =" s"
select =" substring(Ref / @ href,string-length(Ref / @ href)-11,8)" />
< / xsl:call-template>
< / td>
< / tr>
< / xsl:template>
< xsl:template name =" String2Date">
< ; xsl:param name =" s" />
< xsl:variable name =" m"选择= QUOT;字符串(
I have a bunch of files (Playlist files for media player) and I am trying to
create an automatically generated web page that includes the last 20 or 30
of these files. The files are created every week and are named XX-XX-XX.ASX
where the X''s represent the date i.e. 05-22-05.asx
The files are a specific format and will always contain tags like the
following:
<TITLE>My media file title</TITLE>
<AUTHOR>Media file author</AUTHOR>
<Ref href = "mms://media.mydomainname.com/2005/05-01-05.wma" />
I would like to parse these files for the info in the tags, Title, Author,
and Date and then add them to a table on a web page, but I have had no luck
creating the parsing on my own. Can anyone give me a good start in the right
direction using vbscript to get this going.
I especially have trouble pulling the date out since it is at the end of a
tag.. Though I suppose the filename could be used if that could be converted
into a properly formatted date i.e. May 1, 2005
Help?
Your input files appear to be in XML format. If that is the case then use
the MSXML parser. Unfortunately I don''t have any sample code handy. But if
your input is XML let us know and I am sure that someone will be able to get
you started.
--
Mark Schupp
".:mmac:." <lost@sea> wrote in message
news:eo**************@TK2MSFTNGP15.phx.gbl...I have a bunch of files (Playlist files for media player) and I am trying to create an automatically generated web page that includes the last 20 or 30
of these files. The files are created every week and are named XX-XX-XX.ASX where the X''s represent the date i.e. 05-22-05.asx
The files are a specific format and will always contain tags like the
following:
<TITLE>My media file title</TITLE>
<AUTHOR>Media file author</AUTHOR>
<Ref href = "mms://media.mydomainname.com/2005/05-01-05.wma" />
I would like to parse these files for the info in the tags, Title, Author,
and Date and then add them to a table on a web page, but I have had no luck creating the parsing on my own. Can anyone give me a good start in the right direction using vbscript to get this going.
I especially have trouble pulling the date out since it is at the end of a
tag.. Though I suppose the filename could be used if that could be converted into a properly formatted date i.e. May 1, 2005
Help?
It''s the windows media player playlist format, MS says:
"Advanced Stream Redirector (ASX) files are based on the Extensible Markup
Language (XML) syntax".
From this page
http://msdn.microsoft.com/library/de..._reference.asp
the page is for winCE but the syntax is the same as I am using.
Meanwhile I''ll look into MSXML Parser...
thanks
"Mark Schupp" <no****@nospam.com> wrote in message
news:Or**************@TK2MSFTNGP14.phx.gbl...Your input files appear to be in XML format. If that is the case then use
the MSXML parser. Unfortunately I don''t have any sample code handy. But if
your input is XML let us know and I am sure that someone will be able to
get
you started.
--
Mark Schupp
".:mmac:." <lost@sea> wrote in message
news:eo**************@TK2MSFTNGP15.phx.gbl...I have a bunch of files (Playlist files for media player) and I am trying
tocreate an automatically generated web page that includes the last 20 or
30
of these files. The files are created every week and are named
XX-XX-XX.ASXwhere the X''s represent the date i.e. 05-22-05.asx
The files are a specific format and will always contain tags like the
following:
<TITLE>My media file title</TITLE>
<AUTHOR>Media file author</AUTHOR>
<Ref href = "mms://media.mydomainname.com/2005/05-01-05.wma" />
I would like to parse these files for the info in the tags, Title,
Author,
and Date and then add them to a table on a web page, but I have had no
luckcreating the parsing on my own. Can anyone give me a good start in the
rightdirection using vbscript to get this going.
I especially have trouble pulling the date out since it is at the end of
a
tag.. Though I suppose the filename could be used if that could be
convertedinto a properly formatted date i.e. May 1, 2005
Help?
".:mmac:." <lost@sea> wrote in message
news:eo**************@TK2MSFTNGP15.phx.gbl...I have a bunch of files (Playlist files for media player) and I am trying
to create an automatically generated web page that includes the last 20 or
30 of these files. The files are created every week and are named
XX-XX-XX.ASX where the X''s represent the date i.e. 05-22-05.asx
The files are a specific format and will always contain tags like the
following:
<TITLE>My media file title</TITLE>
<AUTHOR>Media file author</AUTHOR>
<Ref href = "mms://media.mydomainname.com/2005/05-01-05.wma" />
I would like to parse these files for the info in the tags, Title, Author,
and Date and then add them to a table on a web page, but I have had no
luck creating the parsing on my own. Can anyone give me a good start in
the right direction using vbscript to get this going.
I especially have trouble pulling the date out since it is at the end of a
tag.. Though I suppose the filename could be used if that could be
converted into a properly formatted date i.e. May 1, 2005
Help?
Here''s a proof of concept using the MSXML Parser
[ShowASX.asp]
<%
CONST PATH = "<<ASX DIRECTORY>>"
Dim xslt, xsl, proc, xml, fso, fld, fc, f
Set xsl = CreateObject("MSXML2.FreeThreadedDOMDocument.4.0")
xsl.Load Server.MapPath("asx2html.xsl")
Set xslt = CreateObject("MSXML2.XSLTemplate.4.0")
Set xslt.stylesheet = xsl
Set proc = xslt.createProcessor()
Set xml = CreateObject("MSXML2.DOMDocument.4.0")
Set fso = CreateObject("Scripting.FileSystemObject")
Set fld = fso.GetFolder(PATH)
Set fc = fld.Files
Response.Write "<table border=''1''>"
For Each f In fc
If Right(f.Name,4) = ".asx" Then
xml.Load Server.MapPath(f.Name)
proc.input = xml
proc.Transform
Response.Write proc.output
End If
Next
Response.Write "</table>"
Set f = Nothing
Set fc = Nothing
Set fld = Nothing
Set xml = Nothing
Set proc = Nothing
Set xslt = Nothing
Set xsl = Nothing
%>
[asx2html.xsl]
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="4.0" indent="yes"/>
<xsl:template match="Asx">
<xsl:apply-templates select="Entry"/>
</xsl:template>
<xsl:template match="Entry">
<tr>
<td><xsl:value-of select="Title"/></td>
<td><xsl:value-of select="Author"/></td>
<td>
<xsl:call-template name="String2Date">
<xsl:with-param name="s"
select="substring(Ref/@href,string-length(Ref/@href)-11,8)"/>
</xsl:call-template>
</td>
</tr>
</xsl:template>
<xsl:template name="String2Date">
<xsl:param name="s"/>
<xsl:variable name="m" select="substring(
这篇关于将文本解析为网页表条目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!