2012-07-25 121 views
0

目前在Visual Studio中我能夠生成XML,但我想在IE中打開結果。如何將XML加載到IE中

標有箭頭的代碼行是我生成XML文件的地方,當我右鍵單擊它時,可以在XML可視化器中看到它。我想在IE中打開XML,以便我可以摺疊並展開節點以便於使用。任何人都可以讓我知道如何在IE瀏覽器中查看XML?

public bool GenerateNETSXML(AccountPRC acct, User currentUser) 
     { 
      bool success = true; 
      int nextTransactionSequence = 0; 
      NetsXMLGen xmlGen = new NetsXMLGen(); 
     ---> string xml = xmlGen.GenerateNetsXml(acct, ref nextTransactionSequence); 
      System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding(); 
      byte[] xmlBytes = encoding.GetBytes(xml); 
      RiskXML riskxml = new RiskXML(true); 
      riskxml.GeneratedDate = DateTime.Now; 
      riskxml.TransactionSequence = nextTransactionSequence; 
      riskxml.NetsXML = xmlBytes; 
      acct.CurrentRisk.LoadRiskXMLs(false); 
      acct.CurrentRisk.RiskXMLs.Add(riskxml); 
      return success; 
     } 

回答

0

其寫入像這樣一個文件:

string s = "<xml><foo></foo></xml>"; 
XmlDocument xdoc = new XmlDocument(); 
xdoc.LoadXml(s); 
xdoc.Save("myfilename.xml"); 

然後在IE中打開該文件,就像任何其他。