Here is the C++ code that has to get the ref attribu" /> Here is the C++ code that has to get the ref attribu" /> Here is the C++ code that has to get the ref attribu"/>

Get attribute value returns a string without namespace

43 Views Asked by At

Here is the sample of XML code :

<xsd:element ref="cbc:UBLVersionID" minOccurs="0" maxOccurs="1">

Here is the C++ code that has to get the ref attribute's value :

    IXMLDOMNamedNodeMap* attributes_map;
    CHK_HR(node->get_attributes(&attributes_map));
    IXMLDOMNode* temp_attr_node;
    attributes_map->getNamedItem(L"ref", &temp_attr_node);
    IXMLDOMAttribute* temp_attr = static_cast<IXMLDOMAttribute*>(temp_attr_node);
    VARIANT attr_value;
    VariantInit(&attr_value);
    temp_attr->get_value(&attr_value);
    std::string attr_value_str = VariantToString(attr_value);
    std::cout << attr_value_str;

This code is actually working pretty well as it is printing UBLVersionID. But I'd like to create an XML using this "ref" value. And I'm pretty sure I'll need to get cbc:UBLVersionID instead. I don't know how I can get the full value of the attribute.

1

There are 1 best solutions below

0
aprotiere On

I found out I had to replace temp_attr->get_value(&attr_value) by temp_attr->get_text(&attr_value)