Click here to Skip to main content
15,917,328 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Questionfile writing help Pin
projectip4-Jul-08 0:38
projectip4-Jul-08 0:38 
QuestionRe: file writing help Pin
CPallini4-Jul-08 0:56
mveCPallini4-Jul-08 0:56 
AnswerRe: file writing help Pin
projectip4-Jul-08 8:55
projectip4-Jul-08 8:55 
QuestionRe: file writing help Pin
CPallini4-Jul-08 23:23
mveCPallini4-Jul-08 23:23 
AnswerRe: file writing help Pin
KarstenK4-Jul-08 0:57
mveKarstenK4-Jul-08 0:57 
AnswerRe: file writing help Pin
vineeshV4-Jul-08 2:02
vineeshV4-Jul-08 2:02 
QuestionRe: file writing help Pin
David Crow4-Jul-08 11:40
David Crow4-Jul-08 11:40 
QuestionCannot open XML File Pin
manju#1234-Jul-08 0:36
manju#1234-Jul-08 0:36 
Hi all.
I am trying to open Xml file using parser..
I am using MSXML2.dll.
When i debug It is throughing Exception in this line
/////////////////////////////
EVAL_HR(objDOMDoc.CreateInstance("Msxml2.DOMDocument.2.0"));
/////////////////////////
In this line i am getting Error...
when I used MSXML4.dll..It is showing error "Cannot open MSXML4.dll..
any suggestions.
Here is the code..
////////////////////////////////
#include "stdafx.h"

#include "stdio.h"
#import "msxml4.dll"
using namespace MSXML2;
 inline void EVAL_HR( HRESULT _hr ) 
   { if FAILED(_hr) throw(_hr); }

int main(int argc, char* argv[])
{
   try 
   {
		IXMLDOMDocumentPtr objDOMDoc;

		EVAL_HR(CoInitialize(NULL)); 
		EVAL_HR(objDOMDoc.CreateInstance(__uuidof(MSXML2::DOMDocument40)));
		_variant_t varXml("C:\\book.xml");
		_variant_t varOut((bool)TRUE);

		objDOMDoc->async = false;
		varOut = objDOMDoc->load(varXml);
		
		if ((bool)varOut == FALSE)
		 throw(0);
		
		printf(_bstr_t(objDOMDoc->xml)) ;
		printf("\n\nPress ENTER to continue...\n");
		getchar();
		//return 0;
	}
	
	catch(...)
	{
		printf("Exception occurred");
		printf("\n\nPress ENTER to continue...\n");
		getchar();
		return -1;
	}
	
	try
	{
		
		MSXML2::IXMLDOMProcessingInstructionPtr pPI = NULL;
		MSXML2::IXMLDOMDocument2Ptr pXMLDoc = NULL;
		MSXML2::IXMLDOMNodePtr pNode = NULL;
		MSXML2::IXMLDOMNodeListPtr pXMLDomNodeList = NULL;
		MSXML2::IXMLDOMNodePtr pRootNode= NULL; 


		EVAL_HR(CoInitialize(NULL));
			
		//	Create MSXML DOM object
		EVAL_HR(pXMLDoc.CreateInstance(("Msxml2.DOMDocument.4.0")));
		
		//	Step 1: Creating the Processing Instruction
		
		pPI = pXMLDoc->createProcessingInstruction
			("xml", "version='1.0' encoding='UTF-8'");

		_variant_t vNullVal;
		vNullVal.vt = VT_NULL;
		pXMLDoc->insertBefore(pPI, vNullVal);

		//	---------------------------------------------
		//	Step 2: Creating the Root Element
		
		_variant_t varNodeType((short)MSXML2::NODE_ELEMENT);

		pRootNode= pXMLDoc->createNode(varNodeType, 
			("Root"),(""));
		pXMLDoc->appendChild(pRootNode);

		//	------------------------------------------
		//	Step 3: Creating Attribute Node
		//MSXML2::IXMLDOMNodePtr pAttNode= NULL; 
		MSXML2::IXMLDOMNodePtr pAttNode= NULL; 
		//pAttNode = pRootNode->appendChild(pXMLDoc->removeChild("attribute"));
		
		
		//	Step 4: Creating attribute name element
		MSXML2::IXMLDOMAttributePtr pattIdAttr = NULL;
		pattIdAttr= pXMLDoc->createAttribute(("Name"));
		pattIdAttr->nodeTypedValue = ("Namevalue");
		pAttNode->attributes->setNamedItem(pattIdAttr);
		//doc.DocumentElement.AppendChild(newElem);

		//xe.Element("address").SetElement("city", "MANCHESTER");
   
		pXMLDoc->save("C:\\s2.xml");
	}
	catch(...)
	{

	}
	

	CoUninitialize();   
	return 1;
}

//////////////////////////////

Hi..
I am Mnaju.I have Completed my B.E Computers Science.Lokking for a job.I am interested in VC++
manju

AnswerRe: Cannot open XML File Pin
KarstenK4-Jul-08 1:03
mveKarstenK4-Jul-08 1:03 
GeneralRe: Cannot open XML File Pin
manju#1234-Jul-08 2:17
manju#1234-Jul-08 2:17 
GeneralRe: Cannot open XML File Pin
manju#1234-Jul-08 2:52
manju#1234-Jul-08 2:52 
AnswerRepost Pin
SandipG 4-Jul-08 1:05
SandipG 4-Jul-08 1:05 
AnswerRe: Cannot open XML File [modified] Pin
mohit_108228-Dec-09 0:49
mohit_108228-Dec-09 0:49 
QuestionCombo Box in and Progress Bar in CListCtrl Pin
sudhir_Kumar3-Jul-08 23:59
sudhir_Kumar3-Jul-08 23:59 
AnswerRe: Combo Box in and Progress Bar in CListCtrl Pin
Iain Clarke, Warrior Programmer4-Jul-08 0:13
Iain Clarke, Warrior Programmer4-Jul-08 0:13 
AnswerRe: Combo Box in and Progress Bar in CListCtrl Pin
Naveen4-Jul-08 0:17
Naveen4-Jul-08 0:17 
Questionblack tint everything on screen behind dialog box Pin
garyofcourse3-Jul-08 23:51
garyofcourse3-Jul-08 23:51 
AnswerRe: black tint everything on screen behind dialog box Pin
Naveen4-Jul-08 0:06
Naveen4-Jul-08 0:06 
Questioncombo box help Pin
projectip3-Jul-08 23:24
projectip3-Jul-08 23:24 
AnswerRe: combo box help Pin
toxcct3-Jul-08 23:32
toxcct3-Jul-08 23:32 
QuestionRe: combo box help Pin
CPallini3-Jul-08 23:35
mveCPallini3-Jul-08 23:35 
AnswerRe: combo box help Pin
Saurabh.Garg3-Jul-08 23:40
Saurabh.Garg3-Jul-08 23:40 
JokeRe: combo box help Pin
Rajesh R Subramanian4-Jul-08 0:38
professionalRajesh R Subramanian4-Jul-08 0:38 
GeneralRe: combo box help Pin
Saurabh.Garg4-Jul-08 2:55
Saurabh.Garg4-Jul-08 2:55 
AnswerRe: combo box help Pin
MANISH RASTOGI4-Jul-08 0:24
MANISH RASTOGI4-Jul-08 0:24 

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.