Click here to Skip to main content
15,907,913 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Converting C# Application to WEB Enabled with ASP.NET . Pin
unitecsoft27-Sep-06 7:09
unitecsoft27-Sep-06 7:09 
QuestionHow to play audio and video files in an aspx page Pin
Meax27-Sep-06 5:21
Meax27-Sep-06 5:21 
QuestionHow to use asp:radio button in datagrid without postback and only single selection Pin
BalasahebK27-Sep-06 5:03
BalasahebK27-Sep-06 5:03 
QuestionImage not being displayed in mozila/firefox.. Pin
ArunKumarParthiban27-Sep-06 4:51
ArunKumarParthiban27-Sep-06 4:51 
AnswerRe: Image not being displayed in mozila/firefox.. Pin
minhpc_bk27-Sep-06 19:40
minhpc_bk27-Sep-06 19:40 
GeneralRe: Image not being displayed in mozila/firefox.. Pin
ArunKumarParthiban27-Sep-06 20:46
ArunKumarParthiban27-Sep-06 20:46 
GeneralRe: Image not being displayed in mozila/firefox.. Pin
minhpc_bk28-Sep-06 0:40
minhpc_bk28-Sep-06 0:40 
QuestionHelp with reading XML with C# Pin
robert11027-Sep-06 4:34
robert11027-Sep-06 4:34 
Hello everyone:

I am struggling with XML (which I am really not good at), the file that I am working with is something like this:
<MotherCompany Name="MC">
 <Company Name="CompanyOne">
    <Department>
     <IsPositions>
        <Temp>
            <MoreNestedDetails></MoreNestedDetails>
        </Temp>
        <IsPerm>
            <MoreNestedDetails></MoreNestedDetails>
        </IsPerm>
        <Intern>
            <MoreNestedDetails></MoreNestedDetails>
        </Intern>
        <Other>
            <MoreNestedDetails></MoreNestedDetails>
        </Other>
      </IsPositions>
    </Department>
 </CompanyOne>
 <Company Name="CompanyTwo">
    <Department>
     <IsPositions>
        <Temp>
            <MoreNestedDetails></MoreNestedDetails>
        </Temp>
        <IsPerm>
            <MoreNestedDetails></MoreNestedDetails>
        </IsPerm>
        <Intern>
            <MoreNestedDetails></MoreNestedDetails>
        </Intern>
        <Other>
            <MoreNestedDetails></MoreNestedDetails>
        </Other>
      </IsPositions>
    </Department>
 </CompanyTwo>
 <Company Name="CompanyThree">
    <Department>
     <IsPositions>
        <Temp>
            <MoreNestedDetails></MoreNestedDetails>
        </Temp>
        <IsPerm>
            <MoreNestedDetails></MoreNestedDetails>
        </IsPerm>
        <Intern>
            <MoreNestedDetails></MoreNestedDetails>
        </Intern>
        <Other>
            <MoreNestedDetails></MoreNestedDetails>
        </Other>
      </IsPositions>
    </Department>
 </CompanyThree>
 <Company Name="CompanyFour">
    <Department>
     <IsPositions>
        <Temp>
            <MoreNestedDetails></MoreNestedDetails>
        </Temp>
        <IsPerm>
            <MoreNestedDetails></MoreNestedDetails>
        </IsPerm>
        <Intern>
            <MoreNestedDetails></MoreNestedDetails>
        </Intern>
        <Other>
            <MoreNestedDetails></MoreNestedDetails>
        </Other>
      </IsPositions>
    </Department>
 </CompanyFour>
</MotherCompany>

Now what I need to do is read the information for each Company under MotherCompany.

A - Since its so freaking nested I am confused as to how to go about collecting the information. Any ideas and suggestion?

B - I tried to use XMLReader; I was doing something like:
<br />
XmlTextReader reader = new XmlTextReader(FileNameWithPath);  <br />
while (reader.Read())<br />
{<br />
  if (reader.Name == "Company")<br />
  {<br />
    if (reader.NodeType == XmlNodeType.Element)<br />
    {<br />
      XmlReader currentNode = reader.ReadSubtree();<br />
      while (currentNode.Read())<br />
      {<br />
        if (currentNode.NodeType == XmlNodeType.Element)<br />
        {<br />
          switch (currentNode.Name)<br />
           {<br />
          case "Temp<br />
            dataCol.MethodList.Add(currentNode.Name);<br />
            break;<br />
          case "IsPerm<br />
            dataCol.MethodList.Add(currentNode.Name);<br />
            break;<br />
          case "Intern<br />
            dataCol.MethodList.Add(currentNode.Name);<br />
            break;<br />
          case "Other<br />
            dataCol.MethodList.Add(currentNode.Name);<br />
            break;<br />
          default:<br />
            break;<br />
          }<br />
        }<br />
      }<br />
    }<br />
  }<br />
}<br />

First of all my reader.ReadSubtree(); reads all the Company Elements, I thought that it would read any thing within the Company Element so I would be able to get data for seperate Company Elements depending on thier the Name attribute. How can I do that in the given scenario? Is there a better way? Like somehow skip to the elements that I need instead of worrying about the nested loops and crap?

Any help will be great and HIGHLY appreciated. Thanks.

PS: At some point I will need to go and get more details and it looks like I am keep nesting while loops for every detailed value; is there a better way of doing that?
AnswerRe: Help with reading XML with C# Pin
Not Active27-Sep-06 4:43
mentorNot Active27-Sep-06 4:43 
GeneralRe: Help with reading XML with C# Pin
robert11027-Sep-06 4:48
robert11027-Sep-06 4:48 
GeneralRe: Help with reading XML with C# Pin
Not Active27-Sep-06 4:56
mentorNot Active27-Sep-06 4:56 
GeneralRe: Help with reading XML with C# Pin
robert11027-Sep-06 9:36
robert11027-Sep-06 9:36 
GeneralRe: Help with reading XML with C# Pin
robert11027-Sep-06 16:06
robert11027-Sep-06 16:06 
GeneralRe: Help with reading XML with C# Pin
Not Active28-Sep-06 2:15
mentorNot Active28-Sep-06 2:15 
GeneralRe: Help with reading XML with C# Pin
robert11028-Sep-06 8:27
robert11028-Sep-06 8:27 
AnswerRe: Help with reading XML with C# Pin
Jim Conigliaro27-Sep-06 10:04
Jim Conigliaro27-Sep-06 10:04 
Questionplz , send me asp.net applicatijon with c# Pin
jignesh_ce00727-Sep-06 4:20
jignesh_ce00727-Sep-06 4:20 
AnswerRe: plz , send me asp.net applicatijon with c# Pin
Not Active27-Sep-06 4:37
mentorNot Active27-Sep-06 4:37 
GeneralRe: plz , send me asp.net applicatijon with c# Pin
_AK_27-Sep-06 18:59
_AK_27-Sep-06 18:59 
QuestionRunning flash file Pin
dptalt27-Sep-06 3:43
dptalt27-Sep-06 3:43 
AnswerRe: Running flash file Pin
minhpc_bk27-Sep-06 19:37
minhpc_bk27-Sep-06 19:37 
Questionplz send some .net projects using asp.net,c#,sqlserver2000 Pin
basha.sk27-Sep-06 3:08
basha.sk27-Sep-06 3:08 
AnswerRe: plz send some .net projects using asp.net,c#,sqlserver2000 Pin
Guffa27-Sep-06 3:12
Guffa27-Sep-06 3:12 
AnswerRe: plz send some .net projects using asp.net,c#,sqlserver2000 Pin
Sathesh Sakthivel27-Sep-06 3:51
Sathesh Sakthivel27-Sep-06 3:51 
Questionhow to clear the text in alot off texeboxs Pin
ashraf hakiem27-Sep-06 2:47
ashraf hakiem27-Sep-06 2:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.