Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XML and XSDs

Status
Not open for further replies.

ccampbell

Programmer
Aug 16, 2001
201
US
Hello,
I need to know how to validate and XML file against an XSD. Here is the code that I have, but it fails on me. Can anyone help?

HRESULT hr = m_plDomDocument.CreateInstance(__uuidof(DOMDocument40));//part of the XML DOM requirements
IXMLDOMSchemaCollectionPtr m_pSchema.CreateInstance("Msxml2.XMLSchemaCache.4.0");


if(m_pSchema)
m_pSchema->add("x-schema:test","test.xsd"); //fails here with the add statement
if (FAILED(hr))
{
_com_error er(hr);
WriteErrorsToLog(er.ErrorMessage());
}

// specify xml file name
m_strFileName = finder.GetFileName();

// convert xml file name string to something COM can handle (BSTR)
_bstr_t bstrFileName;
bstrFileName = m_strFileName.AllocSysString();

// call the IXMLDOMDocumentPtr's load function to load the XML document
variant_t vResult;
try
{
vResult = m_plDomDocument->load(bstrFileName);
.
.
.
}

Any ideas?
 
What kind of error you get? or you just can not start the program?

Ion Filipski
1c.bmp


filipski@excite.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top