473,326 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Set Attribute Fail

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 ???
Nov 12 '05 #1
4 1411
Kevin Tang wrote:
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 ???


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

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #2
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;
}
"Oleg Tkachenko [MVP]" wrote:
Kevin Tang wrote:
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 ???


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

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

Nov 12 '05 #3
I use my SetAttrib function, with the
name = "0"
value = "how are you"

"Oleg Tkachenko [MVP]" wrote:
Kevin Tang wrote:
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 ???


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

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

Nov 12 '05 #4
Kevin Tang wrote:
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

--
Oleg Tkachenko [XML MVP]
http://blog.tkachenko.com
Nov 12 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: MackS | last post by:
I'm new to Python. In general I manage to understand what is happening when things go wrong. However, the small program I am writing now fails with the following message: AttributeError: ClassA...
8
by: Neil Zanella | last post by:
Hello, I would like to know why the W3C decided not to make the following valid XHTML: <input checked type="radio" name="foo" value="bar" />FooBar forcing people to write the following to...
0
by: Jim Bancroft | last post by:
I'm having some trouble mixing "AutoComplete" attributes and transactions with my VB .Net components. Right now, I have two classes --a "parent" and "child"-- that inherit from the .Net...
6
by: Joe | last post by:
Hello All: Does anyone know the difference between the name and id attributes in an Html control? I noticed on PostBack that I can not retrieve the Request.Form("id_value") but I can retrieve...
1
by: Piper707 | last post by:
Hi, I need to generate an XML file for the result which differs based on the value of a "status" attribute. i.e for an error condition it would look something like this: <result...
1
by: aidy | last post by:
Hi, I have created this XML for a test log <SNIP> <?xml version="1.0"?> <?xml-stylesheet type='text/xsl' href='show.xsl'?> <testresults> <test id="TESTID_10"> <teststatus>pass</teststatus>
7
by: Giacomo | last post by:
I work on a page structured like: <h2> ... </h2> <div ="div1" class="show"> ... </div> <h2> ... </h2> <div id="div2" class="show"> ... </div> <h2> ... </h2> <div id="div3" class="show">...
3
by: Jon | last post by:
I have an xml document like so... <?xml version="1.0" encoding="UTF-8"?> <rss version="2.0" xmlns:ng="http://newsgator.com/schema/extensions"> <channel> <title></title> <link></link>...
0
by: Terry Reedy | last post by:
"Casey McGinty" <casey.mcginty@gmail.comwrote in message news:ae3f58470806051341s75052c29s7adcc4c994462618@mail.gmail.com... | On Thu, Jun 5, 2008 at 5:40 AM, Gabriel Rossetti < |...
6
by: CSharper | last post by:
I need to set an atribute to an xml element, I know how to do it with XElement.SetAttributeValue method. But What I am trying to do is, I need to add a attribute with a namespace like the following...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.