Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi there,

I have a little problem using the XMLReader class.

I have a xml file and when I try to read it the xml reader always is "None" after reading. So the object could not be generated.

Could anyone help me to read the XML-file so I have access to all nodes and atrributes?
The programming is in C# by the way.


Here is the file:
XML
<?xml version="1.0" encoding="UTF-8"?>
<!--Arbortext, Inc., 1988-2006, v.4002-->
    <?Pub EntList copy trade nbsp le ge Tgr?>
    <?Pub Inc?>
    <TS-Rolling_Stock>
      <?Pub *0000338779?>
      <Document Type="Maintenance">
        <RevisionSheet></RevisionSheet>
        <TOC/>
        <TOCFigures/>
        <TOCTables/>
        <TOCAbbreviations/>
        <Body>
          <Chapter refname="Chapter.REF.1354188762_479">
            <Head Ref_ID="Head.ID.1354188762_482">Beschreibung</Head>
            <StructureChapter></StructureChapter>
            <Chapter refname="Chapter.REF.1354188762_591">
              <Head Ref_ID="Head.ID.1354188762_594">Aufbau</Head>
            </Chapter>
            <Chapter refname="Chapter.REF.1354188762_607">
              <StructureChapter>
                <TechnicalData refname="TechnicalData.REF.1354188762_659"></TechnicalData>
              </StructureChapter>
            </Chapter>
            <Chapter refname="Chapter.REF.1354188762_739">
              <Chapter refname="Chapter.REF.1354188762_883">
                <Head Ref_ID="Head.ID.1354188762_886">Instandsetzung am Fahrzeug</Head>
                <StructureChapter></StructureChapter>
                <StructureChapter></StructureChapter>
                <Chapter refname="Chapter.REF.1354188762_1039"></Chapter>
                <Chapter refname="Chapter.REF.1354188762_1055"></Chapter>
                <Chapter refname="Chapter.REF.1354188762_1087"></Chapter>
                <Chapter refname="Chapter.REF.1354188762_1183"></Chapter>
              </Chapter>
            </Chapter>
            <Chapter refname="Chapter.REF.1354625172_7705"></Chapter>
          </Chapter>
          <Chapter refname="Chapter.REF.1354188762_479"></Chapter>
        </Body>
        <Appendix></Appendix>
      </Document>
    </TS-Rolling_Stock>




FileStream fileStream = File.OpenRead(xmlSourceFilePath); 
XmlReaderSettings settings; 
settings = new XmlReaderSettings(); 
settings.ConformanceLevel = ConformanceLevel.Auto; 
settings.DtdProcessing = DtdProcessing.Ignore; 
reader = XmlReader.Create(fileStream, settings); 



The object reader is "None". So object could not initate...


Would be great to get help here.
Thanks in advance.
Posted
Updated 27-Aug-13 2:46am
v5
Comments
BotCar 27-Aug-13 7:28am    
While it's nice to see the XML you want to read, it would be even better to see the code that reads it. Could you please post that?
ZurdoDev 27-Aug-13 8:03am    
What do you mean it is "None"?
it-programmer 27-Aug-13 8:45am    
FileStream fileStream = File.OpenRead(xmlSourceFilePath);
XmlReaderSettings settings;
settings = new XmlReaderSettings();
settings.ConformanceLevel = ConformanceLevel.Auto;
settings.DtdProcessing = DtdProcessing.Ignore;
reader = XmlReader.Create(fileStream, settings);


The object reader is "None". So object could not initate...
ZurdoDev 27-Aug-13 8:54am    
Do you mean null? What do you mean by None? Is there an error? Which line are you talking about?

1 solution

Read this article.

Using the XmlReader class with C#[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900