So, in your first example the "Element" element has two child elements named "attribute". Each of these "attribute" elements has an attribute named "name".
Your second example you have one element named "Element", with two attributes named "First" and "Second".
Using SAX, the startElement method would be called whenever an element's starting tag is read. In the first example, when "Element" and "attribute" are read. In the second, when "Element" is read. You then get the attributes as a list of attributes from the Attributes argument. In the first example, Attributes for "Element" would be null, and for the "attribute" elements would be "name". In the second example, Attributes for "Element" would be "First" and "Second".
As to your most recent question, an attribute is not a "child" of an element. But, you can certainly arrange your data however you like, either according to your first approach or the second. You just need to write your code to handle whichever approach you decide on. Does this help?
Mike
At 05:16 PM 11/6/2003 -0600, Jaladurgam, Ramana wrote:
As a work-around is there a way I can specifify attributes as children of an element rather than in <Element att="value"....> pairs?
-----Original Message-----
From: Maksym Kovalenko [mailto:[EMAIL PROTECTED]
Sent: Thursday, November 06, 2003 5:14 PM
To: [EMAIL PROTECTED]
Subject: Re: Retrieve <attribute> values
why do you think you have attributes in the former case? All I see is element with name "Element" and element with name "attribute"
Jaladurgam, Ramana wrote:<!--[if !supportEmptyParas]--><!--[endif]--><!--[if !supportEmptyParas]--><!--[endif]--><!--[if !supportEmptyParas]--><!--[endif]--><!--[if !supportLineBreakNewLine]--><!--[endif]--><!--[if !supportEmptyParas]--><!--[endif]--><!--[if !supportLineBreakNewLine]--><!--[endif]-->
Hello,
I have my elements like:
<Element>
<attribute name="First">FirstAtt</attribute>
<attribute name="Second">SecondAtt</attribute>
</Element>
I am using SAX to parse. But in the startElement(...) method, I am not able to retrieve the attributes. It's fine when the xml file looks like
<Element First="FirstAtt" Second="SecondAtt"/>
What's the approach to retrive the attributes in the former instance?
--------------------------------------------------------------- Michael C. Rawlins, Rawlins EC Consulting www.rawlinsecconsulting.com Using XML with Legacy Business Applications (Addison-Wesley, 2003) www.awprofessional.com/titles/0321154940
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
