Skip to content

Generating XML file issue

George George

Asked Nov 28, 2008, 10:51 PM EST1 answer
Share
LinkedInX

Hello everyone,

I want to generate an XML file like below. My confusion is what technologies could I use to concatenate all information into a single XML document.

The root confusion is, I have a class called teacher which matches the teacher sub-section (ID, name and major) -- which I could use serialization technologies to generate teacher part XML information.

For other parts, like department, I also have a class to represent the information -- I could also use serialization technologies to serialize the information to XML -- but it has no relationship between teachers. So, my confusion is, how to concatenate different parts altogether, like department, club and teachers, and also make the whole XML document looks like below to reflect the relationships and hierarchies between them?

[Code]
<?xml version="1.0" encoding="utf-8"?>
<Department>
  <DepartmentInfo ID ="100">
    <Location> San Jose </Location>
    <Type> Computer Science</Type>
  </DepartmentInfo>
    <Clubs>
      <Club ID="200">
        <Name>Football</Name>
      </Club>
      <Club ID="201">
        <Name>Basketball</Name>
      </Club>
    </Clubs>
    <Teachers>
      <Teacher ID="300">
        <Name>Thomas</Name>
        <Major>Algorithm</Major>
      </Teacher>
      <Teacher ID="301">
        <Name>Zhou</Name>
        <Major>Linear Programming</Major>
      </Teacher>
    </Teachers>
</Department>
[/Code]

thanks in advance,
George

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • Bechir Bejaoui
    +1
    XLINQ is the best solution, I prefer it over the DOM
    +1