CMarkup SetAttrib Method
SetAttrib adds or changes the attribute named
szAttrib in the main position element to have the specified value. If the attribute already exists for the main position element, the value is changed. Otherwise the attribute and its value are added. The method returns
false if there is no main position element.
CMarkup xml; xml.AddElem( "ROOT" ); xml.SetAttrib( "customcode", 35 );
SetAttrib also works when the main position is a processing instruction node. See Node Methods in CMarkup.
Update September 27, 2008: In CMarkup release 10.0 you can specify
MNF_WITHREFS in the optional
nFlags argument to set an attribute value with numeric character references or entities. This tells CMarkup not to double escape ampersands that are followed by an entity name or numeric character reference and semi-colon. Here is an example setting the attribute with an escaped ampersand in the href attribute of an HTML hyperlink.
html.SetAttrib( "href", "http://example.com/?a=1&b=2", CMarkup::MNF_WITHREFS );
AddAttrib method is no longer used and was the same as
SetAttrib. The term "Add" is misleading because an element can only have one attribute of a given name.