Spørgsmål om Xml, Datagrid og Dataset
HejJeg prøver at hente data fra en XML-streng ind i et DataGrid - men jeg ønsker kun at bestemte dele af XML'en ind i grid'et.
Her er min XML, som kommer i en lang "single-line" tekststreng.
<Result><CommercialSchoolActivities> <SchoolNumber>157421</SchoolNumber> <Activity> <Name>0e06ext19102</Name> <ExternalName>lastbilmonteret kran, cert. d</ExternalName> <StartDate>2006-02-20</StartDate> <EndDate>2006-03-03</EndDate> <Description>lastbilmonteret kran, cert. d</Description> <Location> <Description>Randers Tekniske Skole</Description> <StreetAddress>Vester Alle 26</StreetAddress> <PlaceName>Randers</PlaceName> <Telephone>87-100400</Telephone> </Location> <TeachingTime>8.00-15.10</TeachingTime> <TeachingForm>Dagundervisning</TeachingForm> <TeachingPostalcode>8900</TeachingPostalcode> <Price>1000</Price> <ContactPerson>Grete Andersen</ContactPerson> <ContactTelephone>87118512</ContactTelephone> <RunningAdmission>N</RunningAdmission> <IndividualSubjectChoice>N</IndividualSubjectChoice> <ReportingPrinciple>P</ReportingPrinciple> <Quotient>12</Quotient> <RegistrationFormular>Tilmelding</RegistrationFormular> <Subject> <Name>42548</Name> <Level>-</Level> <Description>Lastbilmonteret kran D certifikat</Description> <UvmName>42548</UvmName> <UvmLevel>-</UvmLevel> <UvmDescription>Lastbilmonteret kran D certifikat</UvmDescription> <SubjectStatus>I</SubjectStatus> <DurationInDays>5</DurationInDays> <FKB>2732</FKB> <FKBVersion>1</FKBVersion> <FKBDescription>Lastbilkran</FKBDescription> <Period> <StartDate>2006-02-20</StartDate> <EndDate>2006-03-03</EndDate> <DurationDays>5</DurationDays> </Period></Subject></Activity>....</CommercialSchoolActivities></Result>
Here is my VB.NET Code:
Dim xmlString As StringxmlString = "<Result><CommercialSchoolActivities><SchoolNumber>731401</SchoolNumber><Activity>...."
Dim rdr As New StringReader(xmlString)
Dim ds As New DataSet
ds.ReadXml(rdr)
dgCourses.DataSource = dsdgCourses.DataSource = ds.Tables(3)dgCourses.DataBind()
Problemet med denne kode, er at den kun hiver <Subject>-tabellen fra XML ind, og det ønsker jeg ikke.
Jeg ønsker at hive følgende ind i datagrid'et:
Fra Activity
<Name>0e06ext19102</Name>
Fra Subject
<Description>Lastbilmonteret kran D certifikat</Description>
<DurationInDays>5</DurationInDays>
Fra Period
<StartDate>2006-02-20</StartDate>
<EndDate>2006-03-03</EndDate>
Jeg er på bar bund, så jeg håber nogen kan hjælpe rimeligt hurtigt...evt. med en alternativ løsning.
På forhånd tak.