Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - reading in a nonstandard XML file and displaying contents >Thread Next - Re: reading in a nonstandard XML file and displaying contents Re: reading in a nonstandard XML file and displaying contentsTo: NULL Date: 2/4/2008 1:52:00 PM "javelin" <jmevalentin@g...> wrote in message news:b9541f4d-4ba1-491f-a925-800c0079aa30@l...... > I've "manually" created an XML file in the following format: > > <notes> > <note> > <note_date>1/1/2008</note_date> > <note_text>This is the FIRST note</note_text> > <createdby>John Doe</createdby> > </note> > <note> > <note_date>1/15/2008</note_date> > <note_text>This is the SECOND note</note_text> > <createdby>Donald Trump</createdby> > </note> > <note> > <note_date>2/2/2008</note_date> > <note_text>This is the THIRD note</note_text> > <createdby>Jane Doe</createdby> > </note> > </notes> > > I can easily load and screen print the whole file, but I need to > format it like a table, each <note> tag being a separate row, each > child element being a field. I thought of XSL, but I only know how to > hard code an XSL stylesheet into the XML file. It would have to be > dynamic, since I have a different notes xml file for each client > record, and I may have a different stylesheet for each one. > > Can anyone give me the simplified version of how to handle this (with > or without stylesheets)? > > Thx! Do you mean that you have a different physical notes.xml for each client and they are the same structure? If so you just need to decide where you want to do the transform, I assume client-side as the notes files appear to be on your machine. In that case write an HTML page (or an HTA application) that has an input button of type file to browse for the notes.xml you need to view. It then loads the XSLT and transforms the XML via scripting of the DomDocument. There are many examples of this sort of thing in the MSXML core services SDK, http://msdn2.microsoft.com/en-us/library/ms763742(VS.85).aspx. The basics are: 1) Load the XML file into DomDocument 2) Load the XSLT file. If you are going for re-use then look at IXSLTemplate/IXSLProcessor 3) Perform the transform 4) Use the resulting HTML to populate the innerHTML of a suitable div in the page. -- Joe Fawcett (MVP - XML) http://joe.fawcett.name | ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
