Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xmldocument load error #14654

Closed
cheers00 opened this issue Jun 2, 2015 · 3 comments
Closed

xmldocument load error #14654

cheers00 opened this issue Jun 2, 2015 · 3 comments
Assignees
Labels
area-System.Xml disabled-test The test is disabled in source code against the issue
Milestone

Comments

@cheers00
Copy link

cheers00 commented Jun 2, 2015

I am using nuget pacakge System.Xml.XmlDocument 4.0.0-beta-22819 and when I tried to load xml, I am getting the error System.Xml.XmlException: Root element is missing. for every valid xml file.

Code

            TextReader textReader = File.OpenText(@"xml\document.xml");
            XmlReaderSettings settings = new XmlReaderSettings();
            settings.IgnoreWhitespace = true;
            settings.DtdProcessing = DtdProcessing.Ignore;
            XmlDocument doc = new XmlDocument();
            // doc.LoadXml(textReader.ReadToEnd());

            using (StringReader sr = new StringReader(textReader.ReadToEnd()))
            using (XmlReader reader = XmlReader.Create(sr, settings))
            {
                doc.Load(reader);
            }

XML files

<?xml version="1.0" encoding="utf-8" ?>
<StudentsInformation>
  <GeneralInformation>
    <School>University of XML</School>
    <Department>Department of XML parsing</Department>
  </GeneralInformation>
  <Studentlist>
    <Student id="1" score="100" enrollment="4/30/1789"
             comment="1st and greatest president">George Washington</Student>
    <Student id="2" score="100" enrollment="3/4/1861"
             comment="Civil was. Great president!">Abraham Lincoln</Student>
    <Student id="3" score="99" enrollment="1/20/1993"
             comment="Monica Samille Lewinsky, Cool!">Bill J. Clinton</Student>
    <Student id="4" score="98" enrollment="1/20/2001"
             comment="House price went beyond American's affordability">
      George W. Bush
    </Student>
    <Student id="5" score="99" enrollment="1/20/2009" comment=
             "Ridiculously low interest rate, high house price. $ worthless">
      Barack H. Obama
    </Student>
    <Student id="6" score="35" enrollment="4/30/2011"
             comment="Never qualified to be the president.">Song Li</Student>
  </Studentlist>
</StudentsInformation>

and another xml file

<?xml version="1.0" encoding="utf-8" ?>
<items>
  <item1>test</item1>
  <item1>test2</item1>
  <item1>test3</item1>
</items>
@cheers00
Copy link
Author

cheers00 commented Jun 3, 2015

@stephentoub @krwq
Is there a way to create a command line project and reference corefx component (here System.Xml.XmlDocument) from my local system and debug myself?

@cheers00
Copy link
Author

cheers00 commented Jun 9, 2015

1.0.0-beta6-12005/CoreCLR, the latest version of coreclr has fixed XmlDocument.Load problem.

krwq referenced this issue in krwq/corefx Oct 17, 2015
@krwq
Copy link
Member

krwq commented Oct 17, 2015

Confirmed it doesn't repro.

@krwq krwq closed this as completed Oct 17, 2015
krwq referenced this issue in krwq/corefx Oct 19, 2015
krwq referenced this issue in krwq/corefx Oct 19, 2015
krwq referenced this issue in dotnet/corefx Oct 19, 2015
Add test for issue #1899
@msftgits msftgits transferred this issue from dotnet/corefx Jan 31, 2020
@msftgits msftgits added this to the 1.0.0-rc1 milestone Jan 31, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Jan 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-System.Xml disabled-test The test is disabled in source code against the issue
Projects
None yet
Development

No branches or pull requests

3 participants