all groups > dotnet xml > november 2004 >
You're in the

dotnet xml

group:

Set Attribute Fail



Set Attribute Fail Kevin Tang
11/29/2004 2:13:02 AM
dotnet xml: Dear all,

I am using MS XML Parser 3.0, I want to know what will cause the
"setAttribute" fail in IXMLDOMElement ??

My program is:
extern CComQIPtr<IXMLDOMElement> elem;
ASSERT(elem); // this is a valid element.
Re: Set Attribute Fail Oleg Tkachenko [MVP]
11/29/2004 12:33:57 PM
[quoted text, click to view]

That might be different reasons. Have you any additional information?
What are name and value?

--
Oleg Tkachenko [XML MVP]
Re: Set Attribute Fail Kevin Tang
11/29/2004 6:55:07 PM
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;
}


[quoted text, click to view]
Re: Set Attribute Fail Kevin Tang
11/29/2004 8:17:02 PM
I use my SetAttrib function, with the
name = "0"
value = "how are you"

[quoted text, click to view]
Re: Set Attribute Fail Oleg Tkachenko [MVP]
11/30/2004 1:58:23 PM
[quoted text, click to view]

In XML attribute name cannot start with a number. See the production
rule for Name :
http://www.w3.org/TR/REC-xml/#NT-Name

--
Oleg Tkachenko [XML MVP]
AddThis Social Bookmark Button