From: Huber57 on 1 Apr 2010 09:35 Bob, Thanks much. It looks like a lot of hard work went into it. Now for the BIG question. What do I do with that code? Where would I paste it? Thanks, Doug "Bob Barrows" wrote: > The problem with this sample is there is no root document. If the entire > content was nested inside a single element, perhaps called "dita" (see below > for what I am talking about), then there would be no problem. I tried > creating a test file with your data and opening it in Excel and got the > expected error "document can contain only one top element". So, given your > statement that you were able to open one of these files in Excel, I have to > conclude that you have not shown me the actual structure. There are other > syntax problems with this data (missing quotes, closing tags without opening > tags) that I will have to correct as well. I am going to have to change your > sample data into the correct format to test my code, which will appear at > the bottom of this post. It's quick and dirty, but it is tested and it > works. > > Huber57 wrote: > > Bob, > > > > I would prefer the former (1 spreadsheet, all index terms and > > keywords). > > > > Here is some sample code. > > > <dita> > <title>Records</title> > <prolog> > <author>Mystery Writers</author> > > <metadata><keywords> > <keyword>complication</keyword> > <keyword>complications</keyword> > <keyword>data</keyword> > <keyword>health</keyword> > <keyword>info</keyword> > <keyword>information</keyword> > <keyword>logbook</keyword> > <keyword>logbooks</keyword> > <keyword>my</keyword> > <indexterm>complications</indexterm> > <indexterm>logbook and records, complications</indexterm> > </keywords></metadata> > </prolog> > > <conbody> > <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. > > Vestibulum felis > massa, ultricies eu auctor in, aliquam et mauris. Sed lobortis > > facilisis > nisl, vitae sagittis eros interdum ac. In dolor velit, </p> > </conbody> > <related-links> > <linklist> > <title>Related Links</title> > <link href="otherrecords.dita"><linktext>Other > > Records</linktext></link> > </linklist> > </related-links> > <concept></concept> > </dita> > ************************************************************************************ > dim fso,fldr,fil,xmldoc,nodes, kwnode,itnode, xl,wb,ws,kwrow,itrow > dim pathtofiles > 'replace with your path > pathtofiles="c:\filelib" > set fso=createobject("scripting.filesystemobject") > set fldr=fso.getfolder(pathtofiles & "\dita") > set xmldoc=createobject("msxml2.domdocument") > set xl=createobject("excel.application") > xl.workbooks.add > set wb=xl.workbooks(1) > set ws=wb.sheets(1) > ws.name="dita_values" > kwrow=1 > itrow=1 > ws.cells(kwrow,1).FormulaR1C1="Keywords" > ws.cells(itrow,2).FormulaR1C1="Index Terms" > ws.range("A1:B1").font.bold=true > 'wscript.quit > kwrow=2 > itrow=2 > for each fil in fldr.files > xmldoc.load fil.path > set nodes = nothing > set nodes = xmldoc.selectnodes("//keyword") > if not nodes is nothing then > for each kwnode in nodes > ws.cells(kwrow,1).FormulaR1C1=kwnode.text > kwrow=kwrow+1 > next > else > msgbox "no nodes were found" > end if > set nodes = nothing > set nodes = xmldoc.selectnodes("//indexterm") > if not nodes is nothing then > for each itnode in nodes > ws.cells(itrow,2).FormulaR1C1=itnode.text > itrow=itrow+1 > next > end if > next > wb.saveas pathtofiles & "\keyword_indexterms.xls" > xl.quit > > -- > Microsoft MVP - ASP/ASP.NET - 2004-2007 > Please reply to the newsgroup. This email account is my spam trap so I > don't check it very often. If you must reply off-line, then remove the > "NO SPAM" > > > . >
From: Bob Barrows on 1 Apr 2010 09:43 Into a text file that has a .vbs extension. I called my file "ProcessDita.vbs". You of course can give yours whatever name suits your fancy. Just remember to correct the folder names in the paths in the code. Huber57 wrote: > Bob, > > Thanks much. It looks like a lot of hard work went into it. Now for > the > BIG question. > > What do I do with that code? Where would I paste it? > > Thanks, > > Doug > > "Bob Barrows" wrote: > >> The problem with this sample is there is no root document. If the >> entire >> content was nested inside a single element, perhaps called "dita" >> (see below >> for what I am talking about), then there would be no problem. I tried >> creating a test file with your data and opening it in Excel and got >> the >> expected error "document can contain only one top element". So, >> given your statement that you were able to open one of these files >> in Excel, I have to conclude that you have not shown me the actual >> structure. There are other >> syntax problems with this data (missing quotes, closing tags without >> opening >> tags) that I will have to correct as well. I am going to have to >> change your >> sample data into the correct format to test my code, which will >> appear at >> the bottom of this post. It's quick and dirty, but it is tested and >> it >> works. >> >> Huber57 wrote: >>> Bob, >>> >>> I would prefer the former (1 spreadsheet, all index terms and >>> keywords). >>> >>> Here is some sample code. >>> >> <dita> >> <title>Records</title> >> <prolog> >> <author>Mystery Writers</author> >> >> <metadata><keywords> >> <keyword>complication</keyword> >> <keyword>complications</keyword> >> <keyword>data</keyword> >> <keyword>health</keyword> >> <keyword>info</keyword> >> <keyword>information</keyword> >> <keyword>logbook</keyword> >> <keyword>logbooks</keyword> >> <keyword>my</keyword> >> <indexterm>complications</indexterm> >> <indexterm>logbook and records, complications</indexterm> >> </keywords></metadata> >> </prolog> >> >> <conbody> >> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. >> >> Vestibulum felis >> massa, ultricies eu auctor in, aliquam et mauris. Sed lobortis >> >> facilisis >> nisl, vitae sagittis eros interdum ac. In dolor velit, </p> >> </conbody> >> <related-links> >> <linklist> >> <title>Related Links</title> >> <link href="otherrecords.dita"><linktext>Other >> >> Records</linktext></link> >> </linklist> >> </related-links> >> <concept></concept> >> </dita> >> ************************************************************************************ >> dim fso,fldr,fil,xmldoc,nodes, kwnode,itnode, xl,wb,ws,kwrow,itrow >> dim pathtofiles >> 'replace with your path >> pathtofiles="c:\filelib" >> set fso=createobject("scripting.filesystemobject") >> set fldr=fso.getfolder(pathtofiles & "\dita") >> set xmldoc=createobject("msxml2.domdocument") >> set xl=createobject("excel.application") >> xl.workbooks.add >> set wb=xl.workbooks(1) >> set ws=wb.sheets(1) >> ws.name="dita_values" >> kwrow=1 >> itrow=1 >> ws.cells(kwrow,1).FormulaR1C1="Keywords" >> ws.cells(itrow,2).FormulaR1C1="Index Terms" >> ws.range("A1:B1").font.bold=true >> 'wscript.quit >> kwrow=2 >> itrow=2 >> for each fil in fldr.files >> xmldoc.load fil.path >> set nodes = nothing >> set nodes = xmldoc.selectnodes("//keyword") >> if not nodes is nothing then >> for each kwnode in nodes >> ws.cells(kwrow,1).FormulaR1C1=kwnode.text >> kwrow=kwrow+1 >> next >> else >> msgbox "no nodes were found" >> end if >> set nodes = nothing >> set nodes = xmldoc.selectnodes("//indexterm") >> if not nodes is nothing then >> for each itnode in nodes >> ws.cells(itrow,2).FormulaR1C1=itnode.text >> itrow=itrow+1 >> next >> end if >> next >> wb.saveas pathtofiles & "\keyword_indexterms.xls" >> xl.quit >> >> -- >> Microsoft MVP - ASP/ASP.NET - 2004-2007 >> Please reply to the newsgroup. This email account is my spam trap so >> I >> don't check it very often. If you must reply off-line, then remove >> the "NO SPAM" >> >> >> . -- Microsoft MVP - ASP/ASP.NET - 2004-2007 Please reply to the newsgroup. This email account is my spam trap so I don't check it very often. If you must reply off-line, then remove the "NO SPAM"
From: Huber57 on 1 Apr 2010 10:51 Bob, Thanks much. I have saved the text (removing all of the >>) as a .vbs file. I tried to double click and run it but it gave me an error: Script: C:\Documents and Settings\U39012\Desktop\filepath.vbs Line: 1 Char: 1 Error: Expected statement Code: 800A0400 Source: Microsoft VBScript Compilation Error Here is the code as I have it pasted: ************************************************************************************ dim fso,fldr,fil,xmldoc,nodes, kwnode,itnode, xl,wb,ws,kwrow,itrow dim pathtofiles 'replace with your path pathtofiles="C:\test" set fso=createobject("scripting.filesystemobject") set fldr=fso.getfolder(pathtofiles & "\dita") set xmldoc=createobject("msxml2.domdocument") set xl=createobject("excel.application") xl.workbooks.add set wb=xl.workbooks(1) set ws=wb.sheets(1) ws.name="dita_values" kwrow=1 itrow=1 ws.cells(kwrow,1).FormulaR1C1="Keywords" ws.cells(itrow,2).FormulaR1C1="Index Terms" ws.range("A1:B1").font.bold=true 'wscript.quit kwrow=2 itrow=2 for each fil in fldr.files xmldoc.load fil.path set nodes = nothing set nodes = xmldoc.selectnodes("//keyword") if not nodes is nothing then for each kwnode in nodes ws.cells(kwrow,1).FormulaR1C1=kwnode.text kwrow=kwrow+1 next else msgbox "no nodes were found" end if set nodes = nothing set nodes = xmldoc.selectnodes("//indexterm") if not nodes is nothing then for each itnode in nodes ws.cells(itrow,2).FormulaR1C1=itnode.text itrow=itrow+1 next end if next wb.saveas pathtofiles & "\keyword_indexterms.xls" xl.quit "Bob Barrows" wrote: > Into a text file that has a .vbs extension. I called my file > "ProcessDita.vbs". You of course can give yours whatever name suits your > fancy. Just remember to correct the folder names in the paths in the code. > > Huber57 wrote: > > Bob, > > > > Thanks much. It looks like a lot of hard work went into it. Now for > > the > > BIG question. > > > > What do I do with that code? Where would I paste it? > > > > Thanks, > > > > Doug > > > > "Bob Barrows" wrote: > > > >> The problem with this sample is there is no root document. If the > >> entire > >> content was nested inside a single element, perhaps called "dita" > >> (see below > >> for what I am talking about), then there would be no problem. I tried > >> creating a test file with your data and opening it in Excel and got > >> the > >> expected error "document can contain only one top element". So, > >> given your statement that you were able to open one of these files > >> in Excel, I have to conclude that you have not shown me the actual > >> structure. There are other > >> syntax problems with this data (missing quotes, closing tags without > >> opening > >> tags) that I will have to correct as well. I am going to have to > >> change your > >> sample data into the correct format to test my code, which will > >> appear at > >> the bottom of this post. It's quick and dirty, but it is tested and > >> it > >> works. > >> > >> Huber57 wrote: > >>> Bob, > >>> > >>> I would prefer the former (1 spreadsheet, all index terms and > >>> keywords). > >>> > >>> Here is some sample code. > >>> > >> <dita> > >> <title>Records</title> > >> <prolog> > >> <author>Mystery Writers</author> > >> > >> <metadata><keywords> > >> <keyword>complication</keyword> > >> <keyword>complications</keyword> > >> <keyword>data</keyword> > >> <keyword>health</keyword> > >> <keyword>info</keyword> > >> <keyword>information</keyword> > >> <keyword>logbook</keyword> > >> <keyword>logbooks</keyword> > >> <keyword>my</keyword> > >> <indexterm>complications</indexterm> > >> <indexterm>logbook and records, complications</indexterm> > >> </keywords></metadata> > >> </prolog> > >> > >> <conbody> > >> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. > >> > >> Vestibulum felis > >> massa, ultricies eu auctor in, aliquam et mauris. Sed lobortis > >> > >> facilisis > >> nisl, vitae sagittis eros interdum ac. In dolor velit, </p> > >> </conbody> > >> <related-links> > >> <linklist> > >> <title>Related Links</title> > >> <link href="otherrecords.dita"><linktext>Other > >> > >> Records</linktext></link> > >> </linklist> > >> </related-links> > >> <concept></concept> > >> </dita> > >> ************************************************************************************ > >> dim fso,fldr,fil,xmldoc,nodes, kwnode,itnode, xl,wb,ws,kwrow,itrow > >> dim pathtofiles > >> 'replace with your path > >> pathtofiles="c:\filelib" > >> set fso=createobject("scripting.filesystemobject") > >> set fldr=fso.getfolder(pathtofiles & "\dita") > >> set xmldoc=createobject("msxml2.domdocument") > >> set xl=createobject("excel.application") > >> xl.workbooks.add > >> set wb=xl.workbooks(1) > >> set ws=wb.sheets(1) > >> ws.name="dita_values" > >> kwrow=1 > >> itrow=1 > >> ws.cells(kwrow,1).FormulaR1C1="Keywords" > >> ws.cells(itrow,2).FormulaR1C1="Index Terms" > >> ws.range("A1:B1").font.bold=true > >> 'wscript.quit > >> kwrow=2 > >> itrow=2 > >> for each fil in fldr.files > >> xmldoc.load fil.path > >> set nodes = nothing > >> set nodes = xmldoc.selectnodes("//keyword") > >> if not nodes is nothing then > >> for each kwnode in nodes > >> ws.cells(kwrow,1).FormulaR1C1=kwnode.text > >> kwrow=kwrow+1 > >> next > >> else > >> msgbox "no nodes were found" > >> end if > >> set nodes = nothing > >> set nodes = xmldoc.selectnodes("//indexterm") > >> if not nodes is nothing then > >> for each itnode in nodes > >> ws.cells(itrow,2).FormulaR1C1=itnode.text > >> itrow=itrow+1 > >> next > >> end if > >> next > >> wb.saveas pathtofiles & "\keyword_indexterms.xls" > >> xl.quit > >> > >> -- > >> Microsoft MVP - ASP/ASP.NET - 2004-2007 > >> Please reply to the newsgroup. This email account is my spam trap so > >> I > >> don't check it very often. If you must reply off-line, then remove > >> the "NO SPAM" > >> > >> > >> . > > -- > Microsoft MVP - ASP/ASP.NET - 2004-2007 > Please reply to the newsgroup. This email account is my spam trap so I > don't check it very often. If you must reply off-line, then remove the > "NO SPAM" > > > . >
From: Bob Barrows on 1 Apr 2010 11:00 Err ... you didn't paste in the string of asterisks did you? Huber57 wrote: > Bob, > > Thanks much. I have saved the text (removing all of the >>) as a > .vbs file. > I tried to double click and run it but it gave me an error: > Script: C:\Documents and Settings\U39012\Desktop\filepath.vbs > Line: 1 > Char: 1 > Error: Expected statement > Code: 800A0400 > Source: Microsoft VBScript Compilation Error > > Here is the code as I have it pasted: > > ************************************************************************************ > dim fso,fldr,fil,xmldoc,nodes, kwnode,itnode, xl,wb,ws,kwrow,itrow > dim pathtofiles > 'replace with your path > pathtofiles="C:\test" > set fso=createobject("scripting.filesystemobject") > set fldr=fso.getfolder(pathtofiles & "\dita") > set xmldoc=createobject("msxml2.domdocument") > set xl=createobject("excel.application") > xl.workbooks.add > set wb=xl.workbooks(1) > set ws=wb.sheets(1) > ws.name="dita_values" > kwrow=1 > itrow=1 > ws.cells(kwrow,1).FormulaR1C1="Keywords" > ws.cells(itrow,2).FormulaR1C1="Index Terms" > ws.range("A1:B1").font.bold=true > 'wscript.quit > kwrow=2 > itrow=2 > for each fil in fldr.files > xmldoc.load fil.path > set nodes = nothing > set nodes = xmldoc.selectnodes("//keyword") > if not nodes is nothing then > for each kwnode in nodes > ws.cells(kwrow,1).FormulaR1C1=kwnode.text > kwrow=kwrow+1 > next > else > msgbox "no nodes were found" > end if > set nodes = nothing > set nodes = xmldoc.selectnodes("//indexterm") > if not nodes is nothing then > for each itnode in nodes > ws.cells(itrow,2).FormulaR1C1=itnode.text > itrow=itrow+1 > next > end if > next > wb.saveas pathtofiles & "\keyword_indexterms.xls" > xl.quit > > > "Bob Barrows" wrote: > >> Into a text file that has a .vbs extension. I called my file >> "ProcessDita.vbs". You of course can give yours whatever name suits >> your >> fancy. Just remember to correct the folder names in the paths in the >> code. >> >> Huber57 wrote: >>> Bob, >>> >>> Thanks much. It looks like a lot of hard work went into it. Now >>> for >>> the >>> BIG question. >>> >>> What do I do with that code? Where would I paste it? >>> >>> Thanks, >>> >>> Doug >>> >>> "Bob Barrows" wrote: >>> >>>> The problem with this sample is there is no root document. If the >>>> entire >>>> content was nested inside a single element, perhaps called "dita" >>>> (see below >>>> for what I am talking about), then there would be no problem. I >>>> tried >>>> creating a test file with your data and opening it in Excel and >>>> got >>>> the >>>> expected error "document can contain only one top element". So, >>>> given your statement that you were able to open one of these files >>>> in Excel, I have to conclude that you have not shown me the actual >>>> structure. There are other >>>> syntax problems with this data (missing quotes, closing tags >>>> without >>>> opening >>>> tags) that I will have to correct as well. I am going to have to >>>> change your >>>> sample data into the correct format to test my code, which will >>>> appear at >>>> the bottom of this post. It's quick and dirty, but it is tested and >>>> it >>>> works. >>>> >>>> Huber57 wrote: >>>>> Bob, >>>>> >>>>> I would prefer the former (1 spreadsheet, all index terms and >>>>> keywords). >>>>> >>>>> Here is some sample code. >>>>> >>>> <dita> >>>> <title>Records</title> >>>> <prolog> >>>> <author>Mystery Writers</author> >>>> >>>> <metadata><keywords> >>>> <keyword>complication</keyword> >>>> <keyword>complications</keyword> >>>> <keyword>data</keyword> >>>> <keyword>health</keyword> >>>> <keyword>info</keyword> >>>> <keyword>information</keyword> >>>> <keyword>logbook</keyword> >>>> <keyword>logbooks</keyword> >>>> <keyword>my</keyword> >>>> <indexterm>complications</indexterm> >>>> <indexterm>logbook and records, complications</indexterm> >>>> </keywords></metadata> >>>> </prolog> >>>> >>>> <conbody> >>>> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. >>>> >>>> Vestibulum felis >>>> massa, ultricies eu auctor in, aliquam et mauris. Sed lobortis >>>> >>>> facilisis >>>> nisl, vitae sagittis eros interdum ac. In dolor velit, </p> >>>> </conbody> >>>> <related-links> >>>> <linklist> >>>> <title>Related Links</title> >>>> <link href="otherrecords.dita"><linktext>Other >>>> >>>> Records</linktext></link> >>>> </linklist> >>>> </related-links> >>>> <concept></concept> >>>> </dita> >>>> ************************************************************************************ >>>> dim fso,fldr,fil,xmldoc,nodes, kwnode,itnode, xl,wb,ws,kwrow,itrow >>>> dim pathtofiles >>>> 'replace with your path >>>> pathtofiles="c:\filelib" >>>> set fso=createobject("scripting.filesystemobject") >>>> set fldr=fso.getfolder(pathtofiles & "\dita") >>>> set xmldoc=createobject("msxml2.domdocument") >>>> set xl=createobject("excel.application") >>>> xl.workbooks.add >>>> set wb=xl.workbooks(1) >>>> set ws=wb.sheets(1) >>>> ws.name="dita_values" >>>> kwrow=1 >>>> itrow=1 >>>> ws.cells(kwrow,1).FormulaR1C1="Keywords" >>>> ws.cells(itrow,2).FormulaR1C1="Index Terms" >>>> ws.range("A1:B1").font.bold=true >>>> 'wscript.quit >>>> kwrow=2 >>>> itrow=2 >>>> for each fil in fldr.files >>>> xmldoc.load fil.path >>>> set nodes = nothing >>>> set nodes = xmldoc.selectnodes("//keyword") >>>> if not nodes is nothing then >>>> for each kwnode in nodes >>>> ws.cells(kwrow,1).FormulaR1C1=kwnode.text >>>> kwrow=kwrow+1 >>>> next >>>> else >>>> msgbox "no nodes were found" >>>> end if >>>> set nodes = nothing >>>> set nodes = xmldoc.selectnodes("//indexterm") >>>> if not nodes is nothing then >>>> for each itnode in nodes >>>> ws.cells(itrow,2).FormulaR1C1=itnode.text >>>> itrow=itrow+1 >>>> next >>>> end if >>>> next >>>> wb.saveas pathtofiles & "\keyword_indexterms.xls" >>>> xl.quit >>>> >>>> -- >>>> Microsoft MVP - ASP/ASP.NET - 2004-2007 >>>> Please reply to the newsgroup. This email account is my spam trap >>>> so >>>> I >>>> don't check it very often. If you must reply off-line, then remove >>>> the "NO SPAM" >>>> >>>> >>>> . >> >> -- >> Microsoft MVP - ASP/ASP.NET - 2004-2007 >> Please reply to the newsgroup. This email account is my spam trap so >> I >> don't check it very often. If you must reply off-line, then remove >> the "NO SPAM" >> >> >> . -- Microsoft MVP - ASP/ASP.NET - 2004-2007 Please reply to the newsgroup. This email account is my spam trap so I don't check it very often. If you must reply off-line, then remove the "NO SPAM"
From: Huber57 on 1 Apr 2010 15:08
I did. But then I took it out and tried to run it with no success. I just double clicked on the .vbs file. Now i get this error: Script: C:\Documents and Settings\U39012\Desktop\filepath.vbs Line: 14 Char: 9 Error: Unexpected end of statement Code 800A0401 Source: Microsoft VBScript compilation editor "Bob Barrows" wrote: > Err ... you didn't paste in the string of asterisks did you? > > Huber57 wrote: > > Bob, > > > > Thanks much. I have saved the text (removing all of the >>) as a > > .vbs file. > > I tried to double click and run it but it gave me an error: > > Script: C:\Documents and Settings\U39012\Desktop\filepath.vbs > > Line: 1 > > Char: 1 > > Error: Expected statement > > Code: 800A0400 > > Source: Microsoft VBScript Compilation Error > > > > Here is the code as I have it pasted: > > > > ************************************************************************************ > > dim fso,fldr,fil,xmldoc,nodes, kwnode,itnode, xl,wb,ws,kwrow,itrow > > dim pathtofiles > > 'replace with your path > > pathtofiles="C:\test" > > set fso=createobject("scripting.filesystemobject") > > set fldr=fso.getfolder(pathtofiles & "\dita") > > set xmldoc=createobject("msxml2.domdocument") > > set xl=createobject("excel.application") > > xl.workbooks.add > > set wb=xl.workbooks(1) > > set ws=wb.sheets(1) > > ws.name="dita_values" > > kwrow=1 > > itrow=1 > > ws.cells(kwrow,1).FormulaR1C1="Keywords" > > ws.cells(itrow,2).FormulaR1C1="Index Terms" > > ws.range("A1:B1").font.bold=true > > 'wscript.quit > > kwrow=2 > > itrow=2 > > for each fil in fldr.files > > xmldoc.load fil.path > > set nodes = nothing > > set nodes = xmldoc.selectnodes("//keyword") > > if not nodes is nothing then > > for each kwnode in nodes > > ws.cells(kwrow,1).FormulaR1C1=kwnode.text > > kwrow=kwrow+1 > > next > > else > > msgbox "no nodes were found" > > end if > > set nodes = nothing > > set nodes = xmldoc.selectnodes("//indexterm") > > if not nodes is nothing then > > for each itnode in nodes > > ws.cells(itrow,2).FormulaR1C1=itnode.text > > itrow=itrow+1 > > next > > end if > > next > > wb.saveas pathtofiles & "\keyword_indexterms.xls" > > xl.quit > > > > > > "Bob Barrows" wrote: > > > >> Into a text file that has a .vbs extension. I called my file > >> "ProcessDita.vbs". You of course can give yours whatever name suits > >> your > >> fancy. Just remember to correct the folder names in the paths in the > >> code. > >> > >> Huber57 wrote: > >>> Bob, > >>> > >>> Thanks much. It looks like a lot of hard work went into it. Now > >>> for > >>> the > >>> BIG question. > >>> > >>> What do I do with that code? Where would I paste it? > >>> > >>> Thanks, > >>> > >>> Doug > >>> > >>> "Bob Barrows" wrote: > >>> > >>>> The problem with this sample is there is no root document. If the > >>>> entire > >>>> content was nested inside a single element, perhaps called "dita" > >>>> (see below > >>>> for what I am talking about), then there would be no problem. I > >>>> tried > >>>> creating a test file with your data and opening it in Excel and > >>>> got > >>>> the > >>>> expected error "document can contain only one top element". So, > >>>> given your statement that you were able to open one of these files > >>>> in Excel, I have to conclude that you have not shown me the actual > >>>> structure. There are other > >>>> syntax problems with this data (missing quotes, closing tags > >>>> without > >>>> opening > >>>> tags) that I will have to correct as well. I am going to have to > >>>> change your > >>>> sample data into the correct format to test my code, which will > >>>> appear at > >>>> the bottom of this post. It's quick and dirty, but it is tested and > >>>> it > >>>> works. > >>>> > >>>> Huber57 wrote: > >>>>> Bob, > >>>>> > >>>>> I would prefer the former (1 spreadsheet, all index terms and > >>>>> keywords). > >>>>> > >>>>> Here is some sample code. > >>>>> > >>>> <dita> > >>>> <title>Records</title> > >>>> <prolog> > >>>> <author>Mystery Writers</author> > >>>> > >>>> <metadata><keywords> > >>>> <keyword>complication</keyword> > >>>> <keyword>complications</keyword> > >>>> <keyword>data</keyword> > >>>> <keyword>health</keyword> > >>>> <keyword>info</keyword> > >>>> <keyword>information</keyword> > >>>> <keyword>logbook</keyword> > >>>> <keyword>logbooks</keyword> > >>>> <keyword>my</keyword> > >>>> <indexterm>complications</indexterm> > >>>> <indexterm>logbook and records, complications</indexterm> > >>>> </keywords></metadata> > >>>> </prolog> > >>>> > >>>> <conbody> > >>>> <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. > >>>> > >>>> Vestibulum felis > >>>> massa, ultricies eu auctor in, aliquam et mauris. Sed lobortis > >>>> > >>>> facilisis > >>>> nisl, vitae sagittis eros interdum ac. In dolor velit, </p> > >>>> </conbody> > >>>> <related-links> > >>>> <linklist> > >>>> <title>Related Links</title> > >>>> <link href="otherrecords.dita"><linktext>Other > >>>> > >>>> Records</linktext></link> > >>>> </linklist> > >>>> </related-links> > >>>> <concept></concept> > >>>> </dita> > >>>> ************************************************************************************ > >>>> dim fso,fldr,fil,xmldoc,nodes, kwnode,itnode, xl,wb,ws,kwrow,itrow > >>>> dim pathtofiles > >>>> 'replace with your path > >>>> pathtofiles="c:\filelib" > >>>> set fso=createobject("scripting.filesystemobject") > >>>> set fldr=fso.getfolder(pathtofiles & "\dita") > >>>> set xmldoc=createobject("msxml2.domdocument") > >>>> set xl=createobject("excel.application") > >>>> xl.workbooks.add > >>>> set wb=xl.workbooks(1) > >>>> set ws=wb.sheets(1) > >>>> ws.name="dita_values" > >>>> kwrow=1 > >>>> itrow=1 > >>>> ws.cells(kwrow,1).FormulaR1C1="Keywords" > >>>> ws.cells(itrow,2).FormulaR1C1="Index Terms" > >>>> ws.range("A1:B1").font.bold=true > >>>> 'wscript.quit > >>>> kwrow=2 > >>>> itrow=2 > >>>> for each fil in fldr.files > >>>> xmldoc.load fil.path > >>>> set nodes = nothing > >>>> set nodes = xmldoc.selectnodes("//keyword") > >>>> if not nodes is nothing then > >>>> for each kwnode in nodes > >>>> ws.cells(kwrow,1).FormulaR1C1=kwnode.text > >>>> kwrow=kwrow+1 > >>>> next > >>>> else > >>>> msgbox "no nodes were found" > >>>> end if > >>>> set nodes = nothing > >>>> set nodes = xmldoc.selectnodes("//indexterm") > >>>> if not nodes is nothing then > >>>> for each itnode in nodes > >>>> ws.cells(itrow,2).FormulaR1C1=itnode.text > >>>> itrow=itrow+1 > >>>> next > >>>> end if > >>>> next > >>>> wb.saveas pathtofiles & "\keyword_indexterms.xls" > >>>> xl.quit > >>>> > >>>> -- > >>>> Microsoft MVP - ASP/ASP.NET - 2004-2007 > >>>> Please reply to the newsgroup. This email account is my spam trap > >>>> so > >>>> I > >>>> don't check it very often. If you must reply off-line, then remove > >>>> the "NO SPAM" > >>>> > >>>> > >>>> . > >> > >> -- > >> Microsoft MVP - ASP/ASP.NET - 2004-2007 > >> Please reply to the newsgroup. This email account is my spam trap so > >> I > >> don't check it very often. If you must reply off-line, then remove > >> the "NO SPAM" > >> > >> > >> . > > -- > Microsoft MVP - ASP/ASP.NET - 2004-2007 > Please reply to the newsgroup. This email account is my spam trap so I > don't check it very often. If you must reply off-line, then remove the > "NO SPAM" > > > . > |