Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Building Controls > Parsing nested Tags

Reply
Thread Tools

Parsing nested Tags

 
 
Sam
Guest
Posts: n/a
 
      07-21-2005
Hi,

i'm a bit stuck at the following problem and hope any of you can provide
me wit a nice solution:

I have a company with multiple employees.
When creating a company control i can define a property "employee" of
type Employee (my own created class), but that's only one employee, i
need multiple.
I've found an example where an Employees property is called by using the
ParseChildren(true,"Employees"), but that means that all children are
considered employees, but i also have other properties like "address".
And the example defines the property as type ArrayList. How is the
designer to know what type of tag it is (nowhere is it defined as Employee)?
So i'm looking for a way to identify the <employee> tag when the
employee.get() property is called.

below a sample code of what i've tried or trying to accomplish.

Thanks for any replies.
Sam.


company.aspx:
<company>
<address>Street 1</address>
<employee name="john" />
<employee name="sam" />
</company>


Company.vb:
<ParseChildren(True)> _
Public Class Company
Inherits WebControl

Public Property Address() As String
...
End Property

Private _elements As New ArrayList
<PersistenceMode(PersistenceMode.InnerProperty)> _
Public ReadOnly Property Employee() As ArrayList
Get
Return _employees
End Get
End Property

Private _elements As Employee[]
<PersistenceMode(PersistenceMode.InnerProperty)> _
Public Property Employee() As Employee
Get
Return _employees[?]
End Get
Set(ByVal value As Employee)
_employees[Employee.nr] = value
End Set
End Property
End Class

 
Reply With Quote
 
 
 
 
Teemu Keiski
Guest
Posts: n/a
 
      07-22-2005

"> I've found an example where an Employees property is called by using the
> ParseChildren(true,"Employees"), but that means that all children are
> considered employees, but i also have other properties like "address".
> And the example defines the property as type ArrayList. How is the
> designer to know what type of tag it is (nowhere is it defined as
> Employee)?
> So i'm looking for a way to identify the <employee> tag when the
> employee.get() property is called.
>


Yes, instead of using ArrayList, you should have strong-typed collection in
use. E.g collection typed for Employee object (in case for multiple possible
employee types, typed for the common parent type if the collection stores
them)

--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Parsing nested Tags Sam ASP .Net Web Controls 1 07-22-2005 11:49 AM
All style tags after the first 30 style tags on an HTML page are not applied in Internet Explorer Rob Nicholson ASP .Net 3 05-28-2005 03:11 PM
SAX Parsing - Weird results when parsing content between tags. Naren XML 0 05-11-2004 07:25 PM
RegEx to find CFML tags nested in HTML tags Dean H. Saxe Perl 0 01-03-2004 06:11 PM
Custom Tags within Custom Tags. Ranganath Java 2 10-21-2003 06:14 AM



Advertisments