Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Tidy COM you'll have to download yourself at http://users.rcn.com/creitzel/tidy.html#comatl and help over at... http://tidy.sourceforge.net/. This tool is invaluable if you need to turn sloppy HTML into XHTML or XML.
There's also a .WSC file for almost the same thing.
Note: These are setup to handle MSXML 4.0 so to use 3, just switch the 3 to 4.
XMLTOOLS.WBT
#definesubroutine startMSIE(url) Browser = objectopen("InternetExplorer.Application") Browser.addressbar = @false Browser.statusbar = @false Browser.menubar = @false Browser.toolbar = @false browser.visible = @true browser.navigate(url) ; wait until page loads... WaitForBrowser() return(browser) #endsubroutine #defineSubroutine WaitForBrowser() while Browser.busy || Browser.readystate <> 4 timedelay(0.5) endwhile return #endSubroutine #defineFunction TidyHTML(html) TidyObj = ObjectOpen("TidyCOM.TidyObject") tOptions = TidyObj.Options tOptions.DropFontTags = @false tOptions.AddXMLDecl = @false tOptions.OutputXml = @true tOptions.NumericEntities = @true tOptions.Indent = 0 tOptions.TabSize = 3 tOptions.WrapAttributes = @false tOptions.UppercaseTags = @true tOptions.Wrap = 2000 tOptions.EncloseText = @false XML = TidyObj.TidyMemToMem(html) return(XML) #endFunction #defineFunction CreateXMLDoc(xml) xmlDoc = ObjectOpen("Msxml2.DOMDocument.4.0") xmlDoc.async = @False xmlDoc.loadXML(xml) err = xmlDoc.parseerror if err.errorCode then gosub ShowParseErrors return(xmlDoc) :ShowParseErrors ec = err.errorCode er = err.reason el = err.line elp = err.linepos es = err.srcText message("XML Parse Error", strcat("Error Code: ", ec, @lf, "Reason: ", er, @lf, "Line: ", el, " ", "Column: ", elp, @lf, "Text: ", es)) return #endfunction #defineFunction CreateXMLDocFile(xfile) xmlDoc = ObjectOpen("Msxml2.DOMDocument.4.0") xmlDoc.async = @False xmlDoc.load(xfile) err = xmlDoc.parseerror if err.errorCode then gosub ShowParseErrors return(xmlDoc) :ShowParseErrors ec = err.errorCode er = err.reason el = err.line elp = err.linepos es = err.srcText message("XML Parse Error", strcat("Error Code: ", ec, @lf, "Reason: ", er, @lf, "Line: ", el, " ", "Column: ", elp, @lf, "Text: ", es)) return #endfunction #DefineFunction ParseXML(xml) rdr = ObjectOpen("Msxml2.SAXXMLReader.4.0") wrt = ObjectOpen("Msxml2.MXXMLWriter.4.0") wrt.byteOrderMark = @False wrt.omitXMLDeclaration = @True wrt.indent = @True ;'set the writer to the content handler rdr.contentHandler = wrt rdr.dtdHandler = wrt rdr.PutProperty("http://xml.org/sax/properties/lexical-handler", wrt) rdr.PutProperty("http://xml.org/sax/properties/declaration-handler", wrt) rdr.Parse(xml) newxml = wrt.output objectclose(wrt) objectclose(rdr) return(newxml) #EndFunction #defineFunction TransformViaXSL(xslfile, xml) xmlDoc = ObjectOpen("Msxml2.DOMDocument.4.0") xmlDoc.async = @False xmlDoc.loadXML(ParseXML(xml)) styleDoc = ObjectOpen("Msxml2.DOMDocument.4.0") styleDoc.async = @False styleDoc.load(xslfile) pe = styleDoc.parseError if pe.errorCode <> 0 efile = strcat(dirwindows(0), "wwwbatch.ini") oh = fileopen(efile, "append") filewrite(oh, "MSXML 4.0 Error ------------------------------------>") filewrite(oh, strcat("Error#: ", pe.errorCode)) filewrite(oh, strcat("Line: ", pe.line, " Column: ", pe.linepos)) filewrite(oh, strcat("Source: ", pe.srcText)) filewrite(oh, strcat("Reason: ", pe.reason)) filewrite(oh, strcat("URL: ", pe.url, @crlf)) fileclose(oh) display(2, "Error", pe.reason) endif objectclose(pe) html = xmlDoc.transformNode(styleDoc) objectclose(xmlDoc) objectclose(styleDoc) return(html) #endFunction
XMLTOOLS.WSC
<?xml version="1.0"?> <component> <?component error="true" debug="true"?> <registration description="XMLTools" progid="XMLTools.WSC" version="1.00" classid="{9429b929-fc4e-4d9a-bbe7-4a09a4e29d3e}" > </registration> <public> <method name="CreateXMLDoc"> <PARAMETER name="xml"/> </method> <method name="WaitForBrowser"> <PARAMETER name="br"/> </method> <method name="startMSIE"> <PARAMETER name="url"/> </method> <method name="CreateXMLDocFile"> <PARAMETER name="file"/> </method> <method name="ParseXML"> <PARAMETER name="xml"/> </method> <method name="TidyHTML"> <PARAMETER name="html"/> </method> </public> <implements type="Behavior" id="Behavior"/> <script language="VBScript"> <![CDATA[ function startMSIE(url) dim Browser set Browser = createobject("InternetExplorer.Application") Browser.addressbar = False Browser.statusbar = False Browser.menubar = False Browser.toolbar = False Browser.visible = True Browser.navigate(url) WaitForBrowser(Browser) set startMSIE = Browser end function function CreateXMLDoc(xml) dim xmlDoc set xmlDoc = CreateObject("Msxml2.DOMDocument.4.0") xmlDoc.async = False xmlDoc.loadXML xml set CreateXMLDoc = xmlDoc end function function WaitForBrowser(br) dim WScript set Wscript = CreateObject("WScript.Shell") do while br.busy or br.readyState <> 4 WScript.sleep(500) loop WaitForBrowser = 1 end function function CreateXMLDocFile(file) dim xmlDoc set xmlDoc = CreateObject("Msxml2.DOMDocument.4.0") xmlDoc.async = False xmlDoc.load file set CreateXMLDocFile = xmlDoc end function function ParseXML(xml) 'create the reader and writer Dim rdr, wrt set rdr = CreateObject("Msxml2.SAXXMLReader.4.0") set wrt = CreateObject("Msxml2.MXXMLWriter.4.0") wrt.byteOrderMark = False wrt.omitXMLDeclaration = True wrt.indent = True 'set the writer to the content handler Set rdr.contentHandler = wrt Set rdr.dtdHandler = wrt Set rdr.errorHandler = wrt rdr.putProperty "http://xml.org/sax/properties/lexical-handler", wrt rdr.putProperty "http://xml.org/sax/properties/declaration-handler", wrt 'parse the XML rdr.parse xml 'show the results in a message box ' MsgBox wrt.output ParseXML = wrt.output end function function TidyHTML(html) dim TidyObj, tOptions set TidyObj = createobject("TidyCOM.TidyObject") set tOptions = TidyObj.Options tOptions.DropFontTags = False tOptions.AddXMLDecl = False tOptions.OutputXml = True tOptions.NumericEntities = True tOptions.Indent = True tOptions.TabSize = 3 tOptions.WrapAttributes = False tOptions.UppercaseTags = True tOptions.Wrap = 2000 tOptions.EncloseText = False TidyHTML = TidyObj.TidyMemToMem(html) end function ]]> </script> </component>
Article ID: W17348
File Created: 2007:07:03:14:29:34
Last Updated: 2007:07:03:14:29:34