473,378 Members | 1,542 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Testing for non-existing namespace attribute?

Hello!

I'm using msxml3 in the C++ environment, VC 7.1.3088. How do I know if the
namespace attribute doesn't exist? I want to put it in a std::string, and I
try to do that like this:

string CXmlNodeWrapper::GetNamespaceURI() const
{
if( IsValid() )
{
_bstr_t str = m_xmlnode->GetnamespaceURI();
return static_cast<char*>(str); // <- point of exception
}

return "";
}

m_xmlnode is a MSXML2::IXMLDOMNodePtr; This works fine as long as there is
a namespace attribute, but if the root node doesn't have a namespace
attribute this code throws some exception. How do I do this correctly? I
want to return "" if there is no namespace attribute.
Thanks in advance!

--
Daniel
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Mar 24 '06 #1
1 1038
On Fri, 24 Mar 2006 16:13:17 +0100, Daniel Lidström wrote:
Hello!

I'm using msxml3 in the C++ environment, VC 7.1.3088. How do I know if the
namespace attribute doesn't exist? I want to put it in a std::string, and I
try to do that like this:

string CXmlNodeWrapper::GetNamespaceURI() const
{
if( IsValid() )
{
_bstr_t str = m_xmlnode->GetnamespaceURI();
return static_cast<char*>(str); // <- point of exception
}

return "";
}


I got it:

_bstr_t str = m_xmlnode->GetnamespaceURI();

LPCSTR c_str = (LPCSTR)str;
if( c_str==NULL )
return "";
else
return c_str;
--
Daniel
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Mar 27 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Brian van den Broek | last post by:
Hi all, I'm just starting to employ unit testing (I'm using doctest), and I am uncertain how to handle writing tests where the behaviour being tested is dependant on whether certain file paths...
2
by: Durai | last post by:
Hello All, How to test the "Multiuser testing" in PostgreSQL?. I used the apache bench "ab" tool for this one. The following command execute the "test.php" 50 times concurrently. $ ab -c 1...
7
by: An | last post by:
Dear all, I need to test the elements of an array of chars for non-negativity. I've read the following: "On most architectures testing for non-negativity can be done several bytes at a time." ...
19
by: lihua | last post by:
Hi, Group! I got one question here: We all know that fclose() must be called after file operations to avoid unexpected errors.But there are really cases when you forget to do that!Just like...
2
by: Ken | last post by:
I'd like to know how others approach testing. I work for a bank and there are some fairly paranoid people here. My philosophy is to test only the webforms that were changed. But people here are...
72
by: Jacob | last post by:
I have compiled a set og unit testing recommendations based on my own experience on the concept. Feedback and suggestions for improvements are appreciated: ...
2
by: gamesforums | last post by:
Hi! I've been programming in VB.Net and done testing with TypeMock and MbUnit (Testdriven.net) for about 2months now at work. I can see that my testing skills and particular my knowledge about...
24
by: David | last post by:
Hi list. What strategies do you use to ensure correctness of new code? Specifically, if you've just written 100 new lines of Python code, then: 1) How do you test the new code? 2) How do...
7
by: alito | last post by:
Hi all, I am new to using packages to group my modules. I can't figure out how to run a module that uses relative imports without writing a wrapper that imports that module. Everything I try...
21
by: =?ISO-8859-1?Q?Fad=A5?= | last post by:
Hello guys, I want to do kinda of an A/B split testing on a website I run. I just created a new version but I need to keep both version running and see which one will perform better. First, I'm...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.