我怎么能用xml-reader读取以下XML文件? [英] How could I read the following XML file with a xml-reader ?
本文介绍了我怎么能用xml-reader读取以下XML文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
我使用XMLReader类时遇到一些问题。
我有一个xml文件,当我尝试读取它时,xml阅读器在阅读后始终为无。因此无法生成对象。
任何人都可以帮我读取XML文件,这样我就可以访问所有节点和atrributes了吗?
编程顺便提一下C#。
这是文件:
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 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.
推荐答案
阅读这篇文章。
使用C#的XmlReader类 [ ^ ]
Read this article.
Using the XmlReader class with C#[^]
这篇关于我怎么能用xml-reader读取以下XML文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文