## 29.2 Parsing XML Documents (cont.)

>     string get_attribute(DOMElement* element, string name)
>     {
>        XMLCh* xname = new XMLCh[name.length() + 1];
>        XMLString::transcode(name.c_str(),
>           xname, name.length());
>        XMLCh* xvalue = element->getAttribute(xname);
>        delete xname;
>        return XMLCh_to_string(xvalue);
>     }

- E.g., get the `currency` attribute

> `string attribute_value = get_attribute(
> price_element, "currency");`

prev |top |next