Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / November 2004

Tip: Looking for answers? Try searching our database.

Set Attribute Fail

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kevin Tang - 29 Nov 2004 10:13 GMT
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.
HRESULT hr = elem->setAttribute(name, value); // why it return S_FAIL ???
Oleg Tkachenko [MVP] - 29 Nov 2004 10:33 GMT
> 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.