편집 : 프로젝트는 오래된 프로젝트이고 아래 코드는 XML을 처리하는 클래스 중 하나입니다.XmlReader.Parse()는 무엇을합니까?
오래된 레거시 응용 프로그램에서 xsd를 가져 오는 질문이 있지만 모든 작업이 다음과 같이됩니다. xmlReader.ParseXml (fileName, outputFile); ProcessXml() 메서드에서.
using System;
using System.IO;
using System.Configuration;
using Utilities;
namespace JobProcessor
{
public class XmlJob : Job
{
#region variables
private string ftpServer;
private string ftpUserName;
private string ftpPassWord;
private string ftpDestination;
///<summary>The xml reader used to get validation information from the xmp parsing</summary>
protected XmlReader xmlReader = new XmlReader();
private string outputFile;
public XmlJob(string fileName, string type) : base(fileName, type){
ftpServer = ConfigurationManager.AppSettings[type + "-ftp"];
ftpUserName = ConfigurationManager.AppSettings[type + "-ftpUser"];
ftpPassWord = ConfigurationManager.AppSettings[type + "-ftpPass"];
ftpDestination = ConfigurationManager.AppSettings[type + "-ftpDest"];
}
protected bool ConfigureXmlReader(){
int recType = 0;
try{
//set up the record types (i.e. the elements that trigger a new record in the output
while(ConfigurationManager.AppSettings[type + "-RecordType" + recType.ToString("00")] != null){
xmlReader.AddRecordType(ConfigurationManager.AppSettings[type + "-RecordType" + recType.ToString("00")],recType.ToString("00"));
recType++;
}
//store the number of types
xmlReader.SetNoRecordTypes(recType);
}catch(Exception e){
HandleError("Error loading record types\r\n" + e.ToString() + "\r\n" + e.StackTrace + "\r\n");
return(false);
}
try{
//set up the fields which make up each record type
for(int i=0;i<recType;i++){
xmlReader.AddFieldsList(i,ConfigurationManager.AppSettings[type + "-" + i.ToString("00") + "Fields"]);
}
}catch(Exception e){
HandleError("Error loading field list\r\n" + e.ToString() + "\r\n" + e.StackTrace + "\r\n");
return(false);
}
return(true);
}
public override void RunJob(){
outputFile = Path.Combine(destinationDirectory, Path.GetFileNameWithoutExtension(fileName) + ".flat");
if(!ConfigureXmlReader()){
return;
}
if(!CheckInputFile()){
return;
}
if(!ProcessXml()){
return;
}
if(!Validate()){
return;
}
if(ftpServer!=null && ftpUserName!=null && ftpPassWord!=null && ftpDestination!=null){
if(!FtpFile()){
return;
}
}
MoveOriginalFile();
}
protected virtual bool Validate(){
return(true);
}
protected bool ProcessXml(){
/*
* Process the xml file into a delimited format
*/
try{
xmlReader.ParseXml(fileName,outputFile);
}catch(Exception e){
HandleError("Error parsing XML file\r\n" + e.ToString() + "\r\n" + e.StackTrace + "\r\n");
return(false);
}
return(true);
}
protected bool FtpFile(){
try{
FtpMethods.UploadFile(ftpServer,ftpUserName,ftpPassWord,outputFile,ftpDestination);
}catch(Exception e){
HandleError("Error FTPing file\r\n" + e.ToString() + "\r\n" + e.StackTrace + "\r\n");
return(false);
}
return(true);
}
#endregion
}
}
정확히이 명령은 무엇입니까? F1은 아무 것도 찾지 못했고 Google 검색을 통해 많은 xmlTextReaders를 얻을 수 있습니다.
여기서 xmlReader 인스턴스의 유형은 무엇입니까? –
표시된 코드가 컴파일되지 않습니다. 'XmlReader'는 추상 클래스입니다. –
실제 코드를 게시하십시오. 'XmlReader'는 추상 클래스이며 인스턴스화 할 수 없습니다. –