.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old February 25th, 2004, 07:20 AM
RadioShark RadioShark is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Feb 2004
Posts: 1 RadioShark User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
MSXML: troubles with "insertBefore" in Microsoft Visual C++

Hi Gurus!

I have the simplest xml document (bool.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?

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgramming.NET Development > MSXML: troubles with "insertBefore" in Microsoft Visual C++


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT