Click here to Skip to main content
15,914,413 members
Home / Discussions / XML / XSL
   

XML / XSL

 
GeneralXML schema for VBProj files Pin
Priyananda1-Mar-04 21:16
Priyananda1-Mar-04 21:16 
GeneralTutorial. Pin
Prakash Nadar1-Mar-04 5:19
Prakash Nadar1-Mar-04 5:19 
GeneralRe: Tutorial. Pin
Nick Parker1-Mar-04 9:44
protectorNick Parker1-Mar-04 9:44 
GeneralRe: Tutorial. Pin
ssm12268-Mar-04 16:04
ssm12268-Mar-04 16:04 
Generalto retreive value of a specific attribute Pin
Dpriya1-Mar-04 1:42
Dpriya1-Mar-04 1:42 
Generalpassword protect an xml file Pin
mahesh_chikoo25-Feb-04 2:59
mahesh_chikoo25-Feb-04 2:59 
GeneralRe: password protect an xml file Pin
Clickok25-Feb-04 15:07
Clickok25-Feb-04 15:07 
GeneralMSXML: troubles with "insertBefore" in Microsoft Visual C++ Pin
Bash24-Feb-04 23:19
Bash24-Feb-04 23:19 
Hi Gurus!

I have the simplest xml document (d:\\book.xml):
<?xml version="1.0"?>
<Report>
...
</Report>

I've written the small program (inserting XSL reference in the prolog):

Dim xmlDoc,pi,ref
set xmlDoc = CreateObject ("Msxml.DOMDocument")
xmlDoc.async = false
xmlDoc.resolveExternals = false
xmlDoc.load ("d:\\book.xml")
ref="type=""text/xsl"" href=""mysheet.xsl"""
set pi = xmlDoc.createProcessingInstruction("xml-stylesheet",ref)
xmlDoc.insertBefore pi,xmlDoc.childNodes.item(1)
WScript.Echo(xmlDoc.xml)

It works fine!

Next, I tried to do the same using Microsoft Visual C++:


IXMLDOMDocumentPtr XmlDocPtr;
_bstr_t bstrXMLReport(_T("d:\\book.xml");
VARIANT_BOOL vtResult;
HRESULT hr = XmlDocPtr.CreateInstance(MSXML::CLSID_DOMDocument);

if (FAILED(hr))
{
AfxMessageBox("Failed to CreateInstance(CLSID_DOMDocument)");
return;
};

XmlDocPtr->async=FALSE;
XmlDocPtr->resolveExternals=FALSE;

vtResult=XmlDocPtr->load(bstrXMLReport);
if (vtResult == VARIANT_FALSE)
{
AfxMessageBox("Failed to load XML document");
return;
};

IXMLDOMProcessingInstructionPtr pi;
_bstr_t bstrTarget(_T("xml-stylesheet"));
_bstr_t bstrData(_T("type=\"text/xsl\" href=\"mysheet.xsl\""));
pi=XmlDocPtr->createProcessingInstruction(bstrTarget,bstrData);
BSTR qqq;
pi->get_xml(&qqq);

CComVariant varRef;
IXMLDOMNodePtr pFirst,pXMLNodeCur;
XmlDocPtr->childNodes->get_item(1,&pFirst);
varRef=pFirst;

try
{
XmlDocPtr->insertBefore(pi,t);
AfxMessageBox(XmlDocPtr->xml);
}
catch(_com_error &er)
{
TCHAR szErr[MAX_PATH];
memset(szErr,0,sizeof(szErr));
_tcscpy(szErr,(LPCTSTR)er.Description());
AfxMessageBox(szErr);
};


After that, I've got the exception "The parameter is incorrect."
Why? I suspect the incorrect usage of insertBefore method.


What should I do?

Yours sincerely,
Alex Bash
GeneralLarge XML File Pin
Clickok24-Feb-04 6:08
Clickok24-Feb-04 6:08 
GeneralRe: Large XML File Pin
ian mariano26-Feb-04 1:52
ian mariano26-Feb-04 1:52 
GeneralRe: Large XML File Pin
Rebreath27-Feb-04 11:09
Rebreath27-Feb-04 11:09 
GeneralRe: Large XML File Pin
Clickok27-Feb-04 21:14
Clickok27-Feb-04 21:14 
GeneralRe: Large XML File Pin
ian mariano29-Feb-04 20:00
ian mariano29-Feb-04 20:00 
GeneralRe: Large XML File Pin
ssm12268-Mar-04 16:07
ssm12268-Mar-04 16:07 
GeneralChanging the prolog of XML document Pin
Bash24-Feb-04 5:30
Bash24-Feb-04 5:30 
GeneralUpdated question: Changing the prolog of XML document Pin
Bash24-Feb-04 5:34
Bash24-Feb-04 5:34 
GeneralRe: Updated question: Changing the prolog of XML document Pin
Rebreath27-Feb-04 11:01
Rebreath27-Feb-04 11:01 
QuestionHow to pass multiple values for a param to xsl? Pin
vedbu23-Feb-04 9:59
vedbu23-Feb-04 9:59 
AnswerRe: How to pass multiple values for a param to xsl? Pin
Philip Fitzsimons24-Feb-04 3:23
Philip Fitzsimons24-Feb-04 3:23 
Generalcdata-section-elements Pin
mtone23-Feb-04 5:57
mtone23-Feb-04 5:57 
Generalreading xml schema Pin
Andy H20-Feb-04 5:56
Andy H20-Feb-04 5:56 
GeneralRe: reading xml schema Pin
ian mariano22-Feb-04 11:33
ian mariano22-Feb-04 11:33 
Generalnesting XML tags Pin
Hesham Amin18-Feb-04 22:58
Hesham Amin18-Feb-04 22:58 
GeneralRe: nesting XML tags Pin
ian mariano22-Feb-04 11:42
ian mariano22-Feb-04 11:42 
GeneralRead XSD from embedded resource with VB.NET Pin
mpalmer7818-Feb-04 9:51
mpalmer7818-Feb-04 9:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.