• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 172
  • Last Modified:

Using Stacks with multiple items

Hi

I have an XML and for different nodes, I have different classes. The nodes can be multiples also. So I want to use stacks to put the content of those nodes and their children in the stack.

eg. I have a node called APPLICANT, and we can have multiple APPLICANTS in the XML. So I create an APPLICANT stack, and an APPLICANT class. Now, how do I fill the elements of the class by reading the XML?

my stack creation looks like

Private Applicant_Stack As New Stack

Public Sub CreateApplicantOnStack()
        Dim myApplicant As New Applicant
        Applicant_Stack.Push(myApplicant)
End Sub

Please advise. I am lost on this.

Thanks in advance to all the experts!
0
hmnpa
Asked:
hmnpa
  • 4
  • 3
1 Solution
 
Bob LearnedCommented:
What is the structure of the XML like?  Are you trying to get information from the XML file, and fill Applicant properties, and then push?

Bob
0
 
hmnpaAuthor Commented:
the XML file looks like

<APPLICANTS>
    <APPLICANT A=1 B=2>

    </APPLICANT>

    <APPLICANT A=2 C=3>

    </APPLICANT>
.......
</APPLICANTS>


yes I am trying to get information from XML file into the Applicant class, and then push into the database.
0
 
Bob LearnedCommented:
Is that it, or does each <APPLICANT> have sub nodes?  I only ask, because this seems a bit to simplified, and I wanted to be sure.

Try this as a test for me, so we can decide the proper direction.

Dim dsApplicants As DataSet = New DataSet
dsApplicants.ReadXML(<path to xml file>)

Tell me what happens.  This kind of information would be helpful:
  Number of tables.
  Number of columns for each table.
  Number of rows for each table.

Bob
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
hmnpaAuthor Commented:
Yes, each <APPLICANT> has sub nodes also, which may also be multiple. It is a very complex XML. I just needed to know how to use stacks for handling multiples. Can such complex XMLs be put in a dataset directly?

eg of this XML is

- <APPLICANTS>
- <APPLICANT IsPrimary="N" ApplicantID="String" Fax="String" HomeOwnershipValue="String" SignatureDate="00/00/0000" RaceProvideFlag="N" Action="New" MaritalStatus="Married" FirstName="String" RaceType="AmericanIndianOrAlaskanNative" Email="String" CitizenshipType="Citizen" ImportID="ID000000" BorrowerID="ID000001" DateOfBirth="00/00/0000" RaceOther="String" YearsSchool="0" Gender="F" Generation="String" PropertyTitleHoldValue="String" Age="0" LastName="String" Telephone="String" MiddleName="String" NationalId="String" SpouseID="ID000001">
- <DEPENDANTS>
  <DEPENDANT DependentID="ID000002" Action="New" Age="0" />
  </DEPENDANTS>
- <ALIASES>
  <ALIAS Action="New" FirstName="String" AliasID="ID000003" LastName="String" MiddleName="String" />
  </ALIASES>
- <EMPLOYMENTS>
  <EMPLOYMENT Months="0" PostalCode="String" Region="AL" Action="New" Type="Previous" City="String" Country="String" AddressL2="String" Employer="String" FromDate="00/00/0000" IsSelfEmployed="N" AddressL1="String" ToDate="00/00/0000" Title="String" Profession="String" MonthsInProfession="0" Salary="3.1415926535897932384626433832795" EmploymentID="ID000004" Phone="String" />
  </EMPLOYMENTS>
- <RESIDENCES>
  <RESIDENCE PostalCode="String" Region="AL" Action="New" IsPresent="N" ThoroughfareType="String" City="String" Country="String" AddressL2="String" HouseNumber="String" FromDate="00/00/0000" ResidenceID="ID000005" AddressL1="String" AddressType="Normal" Duration="0" ToDate="00/00/0000" Direction="String" FreeAndClear="true" ApartmentOrUnit="String" ResidenceType="LivingRentFree" RentalHistory="0x30A" />
  </RESIDENCES>
- <DECLARATIONS>
  <DECLARATION DeclarationID="ID000006" Explanation="String" Action="New" Name="AlimonyChildSupportMaintenance" Answer="N" />
  </DECLARATIONS>
  </APPLICANT>
- <APPLICANT IsPrimary="Y" ApplicantID="String" Fax="String" HomeOwnershipValue="String" SignatureDate="00/00/0000" RaceProvideFlag="N" Action="New" MaritalStatus="Married" FirstName="String" RaceType="AmericanIndianOrAlaskanNative" Email="String" CitizenshipType="Citizen" ImportID="ID000000" BorrowerID="ID000001" DateOfBirth="00/00/0000" RaceOther="String" YearsSchool="0" Gender="F" Generation="String" PropertyTitleHoldValue="String" Age="0" LastName="String" Telephone="String" MiddleName="String" NationalId="String" SpouseID="ID000001">
- <DEPENDANTS>
  <DEPENDANT DependentID="ID000002" Action="New" Age="0" />
  </DEPENDANTS>
- <ALIASES>
  <ALIAS Action="New" FirstName="String" AliasID="ID000003" LastName="String" MiddleName="String" />
  </ALIASES>
- <EMPLOYMENTS>
  <EMPLOYMENT Months="0" PostalCode="String" Region="AL" Action="New" Type="Previous" City="String" Country="String" AddressL2="String" Employer="String" FromDate="00/00/0000" IsSelfEmployed="N" AddressL1="String" ToDate="00/00/0000" Title="String" Profession="String" MonthsInProfession="0" Salary="3.1415926535897932384626433832795" EmploymentID="ID000004" Phone="String" />
  </EMPLOYMENTS>
- <RESIDENCES>
  <RESIDENCE PostalCode="String" Region="AL" Action="New" IsPresent="N" ThoroughfareType="String" City="String" Country="String" AddressL2="String" HouseNumber="String" FromDate="00/00/0000" ResidenceID="ID000005" AddressL1="String" AddressType="Normal" Duration="0" ToDate="00/00/0000" Direction="String" FreeAndClear="true" ApartmentOrUnit="String" ResidenceType="LivingRentFree" RentalHistory="0x30A" />
  </RESIDENCES>
- <DECLARATIONS>
  <DECLARATION DeclarationID="ID000006" Explanation="String" Action="New" Name="AlimonyChildSupportMaintenance" Answer="N" />
  </DECLARATIONS>
  </APPLICANT>
  </APPLICANTS>


And this is just one section of the XML. There are other nodes also, so you will get a general idea what it looks like.

Thanks!
0
 
Bob LearnedCommented:
Did you try that ReadXML method that I described above?

Bob
0
 
hmnpaAuthor Commented:
yes I did, I get an error

The same table (VERIFICATION) cannot be the child table in two nested relations.
0
 
Bob LearnedCommented:
Well, then, you are going to have to use the brute-force method:

Example of using an XMLTextReader:
http://www.vbdotnetheaven.com/Code/Apr2003/005.asp

Bob
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now