| Home | Forums | Reviews | Guides | Newsgroups | Register | Search |
![]() |
| Thread Tools |
| .:mmac:. |
|
|
|
| |
|
Mark Schupp
Guest
Posts: n/a
|
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:... > 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? > > |
|
|
|
|
|||
|
|||
| Mark Schupp |
|
|
|
| |
|
.:mmac:.
Guest
Posts: n/a
|
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" <> wrote in message news:... > 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:... >> 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? >> >> > > |
|
|
|
|
|||
|
|||
| .:mmac:. |
|
Chris Hohmann
Guest
Posts: n/a
|
".:mmac:." <lost@sea> wrote in message
news:... >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 <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, </xsl:call-template> </td> </tr> </xsl:template> <xsl:template name="String2Date"> <xsl <xsl:variable name="m" select="substring($s,1,2)"/> <xsl:variable name="d" select="substring($s,4,2)"/> <xsl:variable name="y" select="substring($s,7,2)"/> <xsl:choose> <xsl:when test="$m='01'">January</xsl:when> <xsl:when test="$m='02'">February</xsl:when> <xsl:when test="$m='03'">March</xsl:when> <xsl:when test="$m='04'">April</xsl:when> <xsl:when test="$m='05'">May</xsl:when> <xsl:when test="$m='06'">June</xsl:when> <xsl:when test="$m='07'">July</xsl:when> <xsl:when test="$m='08'">August</xsl:when> <xsl:when test="$m='09'">September</xsl:when> <xsl:when test="$m='10'">October</xsl:when> <xsl:when test="$m='11'">November</xsl:when> <xsl:when test="$m='12'">December</xsl:when> </xsl:choose> <xsl:value-of select="concat(' ',$d,', ')"/> <xsl:choose> <xsl:when test="$m < '30'"><xsl:value-of select="concat('20',$y)"/></xsl:when> <xsl </xsl:choose> </xsl:template> </xsl:stylesheet> Notes: 1. Make sure ShowASX.asp and asx2html.xsl are in the same directory. 2. In ShowASX.asp, you'll need to replace the MSXML version references to whichever version of MSXML you're using, most likely 3.0. So, for example, "MSXML2.DOMDocument.4.0" becomes "MSXML2.DOMDocument.3.0" 3. I used a cached template in this scenario since multiple xml files were being processed by the same xsl stylesheet. This also has the advantage of using a free-threaded xsl document object. As such, the xsl document can be safely stored in the application scope which should yield some performance benefits if the transformed playlists are to be accessed by multiple users. 4. Please consider using ISO standard date formats (YYYY-MM-DD). HTH -Chris Hohmann |
|
|
|
|
|||
|
|||
| Chris Hohmann |
|
.:mmac:.
Guest
Posts: n/a
|
Wow... thats deep, and I almost get what you are doing.. almost...
When I run the page the resulting page source code is only <table border='1'></table> nothing else. I have looked for what could be the problem and can't locate it. No errors are reported on screen. any idea? "Chris Hohmann" <> wrote in message news:Ou%23VXF%... > ".:mmac:." <lost@sea> wrote in message > news:... >>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 > <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, > </xsl:call-template> > </td> > </tr> > </xsl:template> > <xsl:template name="String2Date"> > <xsl > <xsl:variable name="m" select="substring($s,1,2)"/> > <xsl:variable name="d" select="substring($s,4,2)"/> > <xsl:variable name="y" select="substring($s,7,2)"/> > <xsl:choose> > <xsl:when test="$m='01'">January</xsl:when> > <xsl:when test="$m='02'">February</xsl:when> > <xsl:when test="$m='03'">March</xsl:when> > <xsl:when test="$m='04'">April</xsl:when> > <xsl:when test="$m='05'">May</xsl:when> > <xsl:when test="$m='06'">June</xsl:when> > <xsl:when test="$m='07'">July</xsl:when> > <xsl:when test="$m='08'">August</xsl:when> > <xsl:when test="$m='09'">September</xsl:when> > <xsl:when test="$m='10'">October</xsl:when> > <xsl:when test="$m='11'">November</xsl:when> > <xsl:when test="$m='12'">December</xsl:when> > </xsl:choose> > <xsl:value-of select="concat(' ',$d,', ')"/> > <xsl:choose> > <xsl:when test="$m < '30'"><xsl:value-of > select="concat('20',$y)"/></xsl:when> > <xsl > </xsl:choose> > </xsl:template> > </xsl:stylesheet> > > > Notes: > 1. Make sure ShowASX.asp and asx2html.xsl are in the same directory. > > 2. In ShowASX.asp, you'll need to replace the MSXML version references to > whichever version of MSXML you're using, most likely 3.0. So, for example, > "MSXML2.DOMDocument.4.0" becomes "MSXML2.DOMDocument.3.0" > > 3. I used a cached template in this scenario since multiple xml files were > being processed by the same xsl stylesheet. This also has the advantage of > using a free-threaded xsl document object. As such, the xsl document can > be safely stored in the application scope which should yield some > performance benefits if the transformed playlists are to be accessed by > multiple users. > > 4. Please consider using ISO standard date formats (YYYY-MM-DD). > > HTH > -Chris Hohmann > |
|
|
|
|
|||
|
|||
| .:mmac:. |
|
Chris Hohmann
Guest
Posts: n/a
|
".:mmac:." <> wrote in message
news:%... > "Chris Hohmann" <> wrote in message > news:Ou%23VXF%... >> ".:mmac:." <lost@sea> wrote in message >> news:... >>>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 >> <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, >> </xsl:call-template> >> </td> >> </tr> >> </xsl:template> >> <xsl:template name="String2Date"> >> <xsl >> <xsl:variable name="m" select="substring($s,1,2)"/> >> <xsl:variable name="d" select="substring($s,4,2)"/> >> <xsl:variable name="y" select="substring($s,7,2)"/> >> <xsl:choose> >> <xsl:when test="$m='01'">January</xsl:when> >> <xsl:when test="$m='02'">February</xsl:when> >> <xsl:when test="$m='03'">March</xsl:when> >> <xsl:when test="$m='04'">April</xsl:when> >> <xsl:when test="$m='05'">May</xsl:when> >> <xsl:when test="$m='06'">June</xsl:when> >> <xsl:when test="$m='07'">July</xsl:when> >> <xsl:when test="$m='08'">August</xsl:when> >> <xsl:when test="$m='09'">September</xsl:when> >> <xsl:when test="$m='10'">October</xsl:when> >> <xsl:when test="$m='11'">November</xsl:when> >> <xsl:when test="$m='12'">December</xsl:when> >> </xsl:choose> >> <xsl:value-of select="concat(' ',$d,', ')"/> >> <xsl:choose> >> <xsl:when test="$m < '30'"><xsl:value-of >> select="concat('20',$y)"/></xsl:when> >> <xsl >> </xsl:choose> >> </xsl:template> >> </xsl:stylesheet> >> >> >> Notes: >> 1. Make sure ShowASX.asp and asx2html.xsl are in the same directory. >> >> 2. In ShowASX.asp, you'll need to replace the MSXML version references to >> whichever version of MSXML you're using, most likely 3.0. So, for >> example, "MSXML2.DOMDocument.4.0" becomes "MSXML2.DOMDocument.3.0" >> >> 3. I used a cached template in this scenario since multiple xml files >> were being processed by the same xsl stylesheet. This also has the >> advantage of using a free-threaded xsl document object. As such, the xsl >> document can be safely stored in the application scope which should yield >> some performance benefits if the transformed playlists are to be accessed >> by multiple users. >> >> 4. Please consider using ISO standard date formats (YYYY-MM-DD). >> >> HTH >> -Chris Hohmann >> > > Wow... thats deep, and I almost get what you are doing.. almost... > When I run the page the resulting page source code is only > > <table border='1'></table> > > nothing else. > I have looked for what could be the problem and can't locate it. No errors > are reported on screen. > any idea? > > Did you set the PATH constant correctly at the top of the ShowASX.asp page? |
|
|
|
|
|||
|
|||
| Chris Hohmann |
|
.:mmac:.
Guest
Posts: n/a
|
yes, I believe so, I used "E:\www\audio\myasxfiles"
the showasx and XML2html files are in the "audio" directory, I assume it's OK to have it one level up as long as the path is right? I "sniffed" the parser version from a utility on a web page and it found v3.0 and I changed all the references to 3.0 "Chris Hohmann" <> wrote in message news:uJr%... > ".:mmac:." <> wrote in message > news:%... >> "Chris Hohmann" <> wrote in message >> news:Ou%23VXF%... >>> ".:mmac:." <lost@sea> wrote in message >>> news:... >>>>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 >>> <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, >>> </xsl:call-template> >>> </td> >>> </tr> >>> </xsl:template> >>> <xsl:template name="String2Date"> >>> <xsl >>> <xsl:variable name="m" select="substring($s,1,2)"/> >>> <xsl:variable name="d" select="substring($s,4,2)"/> >>> <xsl:variable name="y" select="substring($s,7,2)"/> >>> <xsl:choose> >>> <xsl:when test="$m='01'">January</xsl:when> >>> <xsl:when test="$m='02'">February</xsl:when> >>> <xsl:when test="$m='03'">March</xsl:when> >>> <xsl:when test="$m='04'">April</xsl:when> >>> <xsl:when test="$m='05'">May</xsl:when> >>> <xsl:when test="$m='06'">June</xsl:when> >>> <xsl:when test="$m='07'">July</xsl:when> >>> <xsl:when test="$m='08'">August</xsl:when> >>> <xsl:when test="$m='09'">September</xsl:when> >>> <xsl:when test="$m='10'">October</xsl:when> >>> <xsl:when test="$m='11'">November</xsl:when> >>> <xsl:when test="$m='12'">December</xsl:when> >>> </xsl:choose> >>> <xsl:value-of select="concat(' ',$d,', ')"/> >>> <xsl:choose> >>> <xsl:when test="$m < '30'"><xsl:value-of >>> select="concat('20',$y)"/></xsl:when> >>> <xsl >>> </xsl:choose> >>> </xsl:template> >>> </xsl:stylesheet> >>> >>> >>> Notes: >>> 1. Make sure ShowASX.asp and asx2html.xsl are in the same directory. >>> >>> 2. In ShowASX.asp, you'll need to replace the MSXML version references >>> to whichever version of MSXML you're using, most likely 3.0. So, for >>> example, "MSXML2.DOMDocument.4.0" becomes "MSXML2.DOMDocument.3.0" >>> >>> 3. I used a cached template in this scenario since multiple xml files >>> were being processed by the same xsl stylesheet. This also has the >>> advantage of using a free-threaded xsl document object. As such, the xsl >>> document can be safely stored in the application scope which should >>> yield some performance benefits if the transformed playlists are to be >>> accessed by multiple users. >>> >>> 4. Please consider using ISO standard date formats (YYYY-MM-DD). >>> >>> HTH >>> -Chris Hohmann >>> >> >> Wow... thats deep, and I almost get what you are doing.. almost... >> When I run the page the resulting page source code is only >> >> <table border='1'></table> >> >> nothing else. >> I have looked for what could be the problem and can't locate it. No >> errors are reported on screen. >> any idea? >> >> > Did you set the PATH constant correctly at the top of the ShowASX.asp > page? > |
|
|
|
|
|||
|
|||
| .:mmac:. |
|
Chris Hohmann
Guest
Posts: n/a
|
".:mmac:." <> wrote in message
news:... > "Chris Hohmann" <> wrote in message > news:uJr%... >> ".:mmac:." <> wrote in message >> news:%... >>> "Chris Hohmann" <> wrote in message >>> news:Ou%23VXF%... >>>> ".:mmac:." <lost@sea> wrote in message >>>> news:... >>>>>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 >>>> <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, >>>> </xsl:call-template> >>>> </td> >>>> </tr> >>>> </xsl:template> >>>> <xsl:template name="String2Date"> >>>> <xsl >>>> <xsl:variable name="m" select="substring($s,1,2)"/> >>>> <xsl:variable name="d" select="substring($s,4,2)"/> >>>> <xsl:variable name="y" select="substring($s,7,2)"/> >>>> <xsl:choose> >>>> <xsl:when test="$m='01'">January</xsl:when> >>>> <xsl:when test="$m='02'">February</xsl:when> >>>> <xsl:when test="$m='03'">March</xsl:when> >>>> <xsl:when test="$m='04'">April</xsl:when> >>>> <xsl:when test="$m='05'">May</xsl:when> >>>> <xsl:when test="$m='06'">June</xsl:when> >>>> <xsl:when test="$m='07'">July</xsl:when> >>>> <xsl:when test="$m='08'">August</xsl:when> >>>> <xsl:when test="$m='09'">September</xsl:when> >>>> <xsl:when test="$m='10'">October</xsl:when> >>>> <xsl:when test="$m='11'">November</xsl:when> >>>> <xsl:when test="$m='12'">December</xsl:when> >>>> </xsl:choose> >>>> <xsl:value-of select="concat(' ',$d,', ')"/> >>>> <xsl:choose> >>>> <xsl:when test="$m < '30'"><xsl:value-of >>>> select="concat('20',$y)"/></xsl:when> >>>> <xsl >>>> select="concat('19',$y)"/></xsl >>>> </xsl:choose> >>>> </xsl:template> >>>> </xsl:stylesheet> >>>> >>>> >>>> Notes: >>>> 1. Make sure ShowASX.asp and asx2html.xsl are in the same directory. >>>> >>>> 2. In ShowASX.asp, you'll need to replace the MSXML version references >>>> to whichever version of MSXML you're using, most likely 3.0. So, for >>>> example, "MSXML2.DOMDocument.4.0" becomes "MSXML2.DOMDocument.3.0" >>>> >>>> 3. I used a cached template in this scenario since multiple xml files >>>> were being processed by the same xsl stylesheet. This also has the >>>> advantage of using a free-threaded xsl document object. As such, the >>>> xsl document can be safely stored in the application scope which should >>>> yield some performance benefits if the transformed playlists are to be >>>> accessed by multiple users. >>>> >>>> 4. Please consider using ISO standard date formats (YYYY-MM-DD). >>>> >>>> HTH >>>> -Chris Hohmann >>>> >>> >>> Wow... thats deep, and I almost get what you are doing.. almost... >>> When I run the page the resulting page source code is only >>> >>> <table border='1'></table> >>> >>> nothing else. >>> I have looked for what could be the problem and can't locate it. No >>> errors are reported on screen. >>> any idea? >>> >>> >> Did you set the PATH constant correctly at the top of the ShowASX.asp >> page? >> > > yes, I believe so, I used "E:\www\audio\myasxfiles" > the showasx and XML2html files are in the "audio" directory, I assume it's > OK to have it one level up as long as the path is right? > I "sniffed" the parser version from a utility on a web page and it found > v3.0 and I changed all the references to 3.0 > > You renamed the xsl stylesheet to XML2html? If so, you'll need to adjust ShowASX.asp accordingly. It references a file called asx2html.xsl. Also please post your responses below the quoted text. Top-posting makes it very difficult to follow the flow of the conversation. |
|
|
|
|
|||
|
|||
| Chris Hohmann |
|
.:mmac:.
Guest
Posts: n/a
|
"Chris Hohmann" <> wrote in message news:... > ".:mmac:." <> wrote in message > news:... >> "Chris Hohmann" <> wrote in message >> news:uJr%... >>> ".:mmac:." <> wrote in message >>> news:%... >>>> "Chris Hohmann" <> wrote in message >>>> news:Ou%23VXF%... >>>>> ".:mmac:." <lost@sea> wrote in message >>>>> news:... >>>>>>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 >>>>> <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, >>>>> </xsl:call-template> >>>>> </td> >>>>> </tr> >>>>> </xsl:template> >>>>> <xsl:template name="String2Date"> >>>>> <xsl >>>>> <xsl:variable name="m" select="substring($s,1,2)"/> >>>>> <xsl:variable name="d" select="substring($s,4,2)"/> >>>>> <xsl:variable name="y" select="substring($s,7,2)"/> >>>>> <xsl:choose> >>>>> <xsl:when test="$m='01'">January</xsl:when> >>>>> <xsl:when test="$m='02'">February</xsl:when> >>>>> <xsl:when test="$m='03'">March</xsl:when> >>>>> <xsl:when test="$m='04'">April</xsl:when> >>>>> <xsl:when test="$m='05'">May</xsl:when> >>>>> <xsl:when test="$m='06'">June</xsl:when> >>>>> <xsl:when test="$m='07'">July</xsl:when> >>>>> <xsl:when test="$m='08'">August</xsl:when> >>>>> <xsl:when test="$m='09'">September</xsl:when> >>>>> <xsl:when test="$m='10'">October</xsl:when> >>>>> <xsl:when test="$m='11'">November</xsl:when> >>>>> <xsl:when test="$m='12'">December</xsl:when> >>>>> </xsl:choose> >>>>> <xsl:value-of select="concat(' ',$d,', ')"/> >>>>> <xsl:choose> >>>>> <xsl:when test="$m < '30'"><xsl:value-of >>>>> select="concat('20',$y)"/></xsl:when> >>>>> <xsl >>>>> select="concat('19',$y)"/></xsl >>>>> </xsl:choose> >>>>> </xsl:template> >>>>> </xsl:stylesheet> >>>>> >>>>> >>>>> Notes: >>>>> 1. Make sure ShowASX.asp and asx2html.xsl are in the same directory. >>>>> >>>>> 2. In ShowASX.asp, you'll need to replace the MSXML version references >>>>> to whichever version of MSXML you're using, most likely 3.0. So, for >>>>> example, "MSXML2.DOMDocument.4.0" becomes "MSXML2.DOMDocument.3.0" >>>>> >>>>> 3. I used a cached template in this scenario since multiple xml files >>>>> were being processed by the same xsl stylesheet. This also has the >>>>> advantage of using a free-threaded xsl document object. As such, the >>>>> xsl document can be safely stored in the application scope which >>>>> should yield some performance benefits if the transformed playlists >>>>> are to be accessed by multiple users. >>>>> >>>>> 4. Please consider using ISO standard date formats (YYYY-MM-DD). >>>>> >>>>> HTH >>>>> -Chris Hohmann >>>>> >>>> >>>> Wow... thats deep, and I almost get what you are doing.. almost... >>>> When I run the page the resulting page source code is only >>>> >>>> <table border='1'></table> >>>> >>>> nothing else. >>>> I have looked for what could be the problem and can't locate it. No >>>> errors are reported on screen. >>>> any idea? >>>> >>>> >>> Did you set the PATH constant correctly at the top of the ShowASX.asp >>> page? >>> >> >> yes, I believe so, I used "E:\www\audio\myasxfiles" >> the showasx and XML2html files are in the "audio" directory, I assume >> it's OK to have it one level up as long as the path is right? >> I "sniffed" the parser version from a utility on a web page and it found >> v3.0 and I changed all the references to 3.0 >> >> > You renamed the xsl stylesheet to XML2html? If so, you'll need to adjust > ShowASX.asp accordingly. It references a file called asx2html.xsl. Also > please post your responses below the quoted text. Top-posting makes it > very difficult to follow the flow of the conversation. > Sorry no I didn't rename the stylesheet, I just called it the wrong name in my hurried reply. I used the name you gave it. |
|
|
|
|
|||
|
|||
| .:mmac:. |
|
.:mmac:.
Guest
Posts: n/a
|
"Chris Hohmann" <> wrote in message news:%... > "Chris Hohmann" <> wrote in message > news:... >> ".:mmac:." <> wrote in message >> news:... >>> "Chris Hohmann" <> wrote in message >>> news:uJr%... >>>> ".:mmac:." <> wrote in message >>>> news:%... >>>>> "Chris Hohmann" <> wrote in message >>>>> news:Ou%23VXF%... >>>>>> ".:mmac:." <lost@sea> wrote in message >>>>>> news:... >>>>>>>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 > [snip] > > Ugh! The extention on your playlist files is ".ASX", not ".asx" right? > Because your original post is ambigous on that point. Replace the > following line in ShowASX.asp: > > If Right(f.Name,4) = ".asx" Then > > With this line: > > If UCase(Right(f.Name,4)) = ".ASX" Then > > no, they are all lowercase, but the change makes sense anyway. I didn't know this would be case sensitive but I should 'cause I ran into that before. Bearing that in mind, is this line" <xsl:template match="Asx">" in the style sheet OK as far as case goes? |
|
|
|
|
|||
|
|||
| .:mmac:. |
|
|
|
| |
![]() |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Parsing XML into PHP to insert into a MySQL DB | impulse() | XML | 0 | 10-13-2006 03:05 PM |
| Parsing text into dates? | Thomas W | Python | 9 | 05-17-2005 11:20 PM |
| Parsing a text file into an array | Scott | Perl | 1 | 08-17-2004 04:21 PM |
| How do I insert date of web page into the web page? | Bob K. | HTML | 5 | 05-16-2004 10:06 AM |
| parsing data file into mysql table - help | smrtalec | Perl Misc | 3 | 02-23-2004 11:49 PM |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc..
SEO by vBSEO ©2010, Crawlability, Inc. |




