XSLT in VC++.NET 7.0: Output in Web Browser
I have carefully studied (1) Chapter 4, XSLT of "Beginning XML", 2nd Edition by D. Hunter, et. al. and (2) Chapter 21, Transforming XML of Microsoft Visual C++ .NET Step by Step, by J. Templeman & A. Olsen. I did "Build" and executed the attached "CppXsl" program of (2) on my VC++ .NET (7.0) - Windows XP Pro PC and I got the following:
"Usage: CppXsl xml-file stylesheet
Press any key to continue" on my console.
But I do not know how to extract the data of 'Volcanoes' from the XML file and merge with HTML to create the output in the web browser. Please help and advise me how I can get the output in my web browser.
Thanks in advance,
SHC
/////--CppXsl.cpp--/////
// This is the main project file for VC++ application project
// generated using an Application Wizard.
#include "stdafx.h"
#using <mscorlib.dll>
#using <System.xml.dll>
using namespace System;
using namespace System::Xml;
using namespace System::Xml::XPath;
using namespace System::Xml::Xsl;
// This is the entry point for this application
#ifdef _UNICODE
int wmain(void)
#else
int main(int argc, char* argv[])
#endif
{
// Check for required arguments
if (argc < 3)
{
Console::WriteLine(S"Usage: CppXsl xml-file stylesheet");
return -1;
}
String* path = new String(argv[1]);
String* xslpath = new String(argv[2]);
try
{
// Create the XmlDocument to parse the file
XmlDocument* doc = new XmlDocument();
// Load the file
doc->Load(path);
// Create the navigator and position it
XPathNavigator* nav = doc->CreateNavigator();
nav->MoveToRoot();
// Create the XslTransform and load it
XslTransform* xslt = new XslTransform();
xslt->Load(xslpath);
// Create a writer for output
XmlTextWriter* xtw = new XmlTextWriter(Console::Out);
xtw->Formatting = Formatting::Indented;
// Do the transformation
xslt->Transform(nav, 0, xtw);
}
catch(Exception* pe)
{
Console::WriteLine(pe->Message);
}
return 0;
}
Scott Chang
__________________
Scott Chang
|