> I am using MS XML Parser 3.0, I want to know what will cause the
> "setAttribute" fail in IXMLDOMElement ??
[quoted text clipped - 3 lines]
> ASSERT(elem); // this is a valid element.
> HRESULT hr = elem->setAttribute(name, value); // why it return S_FAIL ???
That might be different reasons. Have you any additional information?
What are name and value?

Signature
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Kevin Tang - 30 Nov 2004 02:55 GMT
I have a function is this:
bool SetAttrib(CComQIPtr<IXMLDOMElement> &_elem, CString _AttribName,
CString _AttribValue)
{
ASSERT(_elem); // Check for valid
_AttribValue.TrimLeft();
_AttribValue.TrimRight();
try {
BSTR name;
name = _AttribName.AllocSysString();
VARIANT value;
value.vt = VT_BSTR;
value.bstrVal = _AttribValue.AllocSysString();
HRESULT hr = _elem->setAttribute(name, value);
::SysFreeString(name);
::SysFreeString(value.bstrVal);
value.vt = VT_EMPTY;
if (hr == S_OK)
return true;
}
catch (_com_error &e)
{
dump_com_error(e);
}
return false;
}
> > I am using MS XML Parser 3.0, I want to know what will cause the
> > "setAttribute" fail in IXMLDOMElement ??
[quoted text clipped - 6 lines]
> That might be different reasons. Have you any additional information?
> What are name and value?
Kevin Tang - 30 Nov 2004 04:17 GMT
I use my SetAttrib function, with the
name = "0"
value = "how are you"
> > I am using MS XML Parser 3.0, I want to know what will cause the
> > "setAttribute" fail in IXMLDOMElement ??
[quoted text clipped - 6 lines]
> That might be different reasons. Have you any additional information?
> What are name and value?
Oleg Tkachenko [MVP] - 30 Nov 2004 11:58 GMT
> I use my SetAttrib function, with the
> name = "0"
In XML attribute name cannot start with a number. See the production
rule for Name :
http://www.w3.org/TR/REC-xml/#NT-Name

Signature
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com