Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries [Thread Prev] >Thread Next - Re: How do I get the value out of an IXMLDOMNodePtr? How do I get the value out of an IXMLDOMNodePtr?To: NULL Date: 11/1/2008 2:15:00 PM MSDN's examples only seem to show how to get the xml string out of a
node.
I don't want the xml string! That's why I'm using your XML library in
the first place sillies!
Anyway, I've been pooring over the documentation for hours and I can't
seem to come up with a way to get my value out with anything but
GetText, which seems to come back with all child node values as well.
I just want the one single value, preferably as an unsigned int.
xml:
<economy>
<good>
<name>Energy</name>
<value>12</value>
<tech>1</tech>
</good>
<good>
<name>Ice</name>
<value>24</value>
<tech>1</tech>
</good>
<good>
<name>Water</name>
<value>30</value>
<tech>1</tech>
</good>
</economy>
code:
// The list is loaded and valid. checked the names and the xml output
already
//
void DataManager::ParseGoods(MSXML2::IXMLDOMNodeListPtr &
goodXMLNodes)
{
for(Good::ID id = 0; id < static_cast<unsigned>(goodXMLNodes-
>Getlength()); ++id)
{
MSXML2::IXMLDOMNodePtr node = goodXMLNodes->nextNode();
Good good;
good.m_ID = id;
std::string nodeName = node->nodeName;
std::string nodeText = node->text;
for(node = node->GetfirstChild(); node != NULL; node = node-
>GetnextSibling())
{
nodeName = node->nodeName;
if( nodeName == "name" || nodeName == "Name" )
{
good.m_name = node->text;
}
if( nodeName == "value" || nodeName == "Value" )
{
// This throws an exception. Nowhere on MSDN can I find
what kind of exception or why it was thrown.
// I assume there is some conversion problem...
// How do I get my unsigned int out here?
good.m_baseValue = node->GetnodeValue().operator unsigned
int();
}
}
// Check that all fields got filled out
}
}
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
