Re: MSXML4 (Document Object Model XML), read the file, read the
variables, fill it, send over socket
Good morning Pete,
thanks.
One question.
BEFORE:
- <root>
- <header eventId="" version="" eventName="" timeStamp="">
<location lineNumber="" stationNumber="" stationIdent=""
toolPosition="0" processName="" application="" />
</header>
- <event>
<Processed identifier="" />
</event>
- <body>
<identifierType></identifierType>
AFTER --> Result
- <root>
- <header eventId="321" version="3.01" eventName="evTest"
timeStamp="16.02.2008">
<location lineNumber="H-45 stationNumber="M-03"
stationIdent="9004534"
toolPosition="0" processName="Pr_Start" application="Connection" />
</header>
- <event>
<Processed identifier="2008-02-16-17:25:22 001" />
</event>
- <body>
<identifierType>Type-001</identifierType>
Can you give me a little bit more instruction.
Thanks.
Have a nice Sunday.
Best wishes Andreas
#include "stdafx.h"
#import <msxml4.dll>
#include <iostream>
#include <cstdlib>
#ifdef UNICODE
#define _tout wcout
#else
#define _tout cout
#endif
int _tmain(int argc, _TCHAR* argv[])
{
HRESULT hr = ::CoInitialize ( NULL );
if (SUCCEEDED ( hr ) )
{
MSXML2::IXMLDOMDocument2Ptr pDomDocument;
hr = pDomDocument.CreateInstance (__uuidof
(MSXML2::DOMDocument40));
if (SUCCEEDED (hr))
{
pDomDocument->async = VARIANT_FALSE ;
pDomDocument->validateOnParse = VARIANT_TRUE;
pDomDocument->resolveExternals = VARIANT_TRUE;
if ( VARIANT_TRUE == pDomDocument->load (
_T("http://rss.slashdot.org/Slashdot/slashdot") ) )
{
std::_tout << _T("Success") << std::endl;
// To prove to yourself that the file actually was downloaded,
save it
locally.
pDomDocument->save ( _T("Downloaded.xml") );
}
else
{
MSXML2::IXMLDOMParseErrorPtr pError = NULL;
if ((pError = pDomDocument->parseError) != NULL)
{
hr = pError->errorCode;
std::_tout << _T("Error Code: ") << pError->errorCode <<
std::endl;
std::_tout << _T("Reason: ") << pError->Getreason () <<
std::endl;
}
}
}
pDomDocument.Release ();
::CoUninitialize ();
}
return SUCCEEDED (hr) ? EXIT_SUCCESS : EXIT_FAILURE;