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 - BSTR - CString

Status
Not open for further replies.

OneSource

Programmer
Jun 18, 2002
22
US
Hi and thanks for reading this post.

I'm using loadXML to get the XML from a web page and get_xml to assign the XML data to a BSTR variable. I am having difficulty displaying the BSTR variable in a CString edit control (m_editWB) on a form. It should be simple, but I can't figure out how to display the BSTR value in the edit control. Here's a snippet of my code:

Code:
...
pBody->get_innerText(&bStrAspText);

hr = pIXMLDOMDocument2->loadXML(bStrAspText, &sResult);

if SUCCEEDED(hr)
{
	pIXMLDOMDocument2->get_xml( &bstrValue );
	m_editWB = bstrValue;
	UpdateData( false );
}
...

Can anyone help me out?

FYI, I am using Visual C++ 6.0.

Thanks.
 
You should be able to use strMyCString = myBSTR.
Can you confirm that your BSTR has a value?
BSTR's are just pointers so it may be that the required memory space isn't being allocated (this can be done using SysAllocString()) and the BSTR is pointing to nothing.

I'm sorry this is A bit vague, but I've tried this and you should just be able to use "=" so I can only assume at this stage that the problem is with the BSTR itself.
Let us know of any more info you think may be helpful.
CMR
 
CMR, thanks for the reply. I was able to figure the problem out. It wasn't actually the BSTR variable, but the way that "loadXML" operates that prevented me from getting at the data.

Thanks again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top