Category Archives: XML

get xml string with encoding from MSXML

// First step is add encoding to processing instruction MSXML::IXMLDOMProcessingInstructionPtr pXMLProcessingNode = pXMLDoc->createProcessingInstruction(“xml”, ” version=’1.0′ encoding=’UTF-8′”); _variant_t vtObject; vtObject.vt = VT_DISPATCH; vtObject.pdispVal = pXMLRootElem; vtObject.pdispVal->AddRef(); pXMLDoc->insertBefore(pXMLProcessingNode,vtObject); // second step is writing the document to IStream CComPtr<IStream> spStream; hr = ::CreateStreamOnHGlobal(NULL,TRUE,&spStream); … Continue reading

Posted in CPP, XML | Leave a comment

XSLT support

Qt QXmlQuery class provides experimental support of XSLT (XSLT supported features).  Open source solution Xalan-C++ is no longer actively maintained. MSXML IXSLTemplate interface provides support for XSLT transform and seems to be the most mature solution on Windows Platform for … Continue reading

Posted in XML | 1 Comment

Use XPATH to filter “xml:lang” via MSXML in VC6

#include "stdafx.h"#include <TCHAR.H>#include <stdio.h>#include <time.h>#import "msxml4.dll"using namespace MSXML2; inline void EVAL_HR( HRESULT _hr )    { if FAILED(_hr) throw(_hr); } void printMSXMLError(const IXMLDOMDocument2Ptr& pXMLDoc){    try    {        IXMLDOMParseErrorPtr pError = NULL;        EVAL_HR(pXMLDoc->get_parseError(&pError) );        _ftprintf(stderr, pError->reason);    }    catch(…)    {//Exception handling    }} int … Continue reading

Posted in XML | Leave a comment

empty base64Binary value in XML

MSXML4.0 reports error when an XML element has empty value of base64Binary type. The following url explained that empty value is valid Furthermore, the Second Edition of XMLSchema [2] has a regular expression for base64Binary which explicitly allows empty (base64) … Continue reading

Posted in XML | Leave a comment