2016-09-15 17 views
-1

を解析中に問題を持つことは、私はサーバIDと名前を取得しようとしていますサンプルXMLSSISスクリプトタスク - ここでは、XML

<?xml version="1.0" encoding="utf-16"?> 
 
<ServerInfoArrayResult xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
 
    <Result xmlns="http://www.smartertools.com/smarterstats/ServerAdmin.asmx">true</Result> 
 
    <ResultCode xmlns="http://www.smartertools.com/smarterstats/ServerAdmin.asmx">1</ResultCode> 
 
    <Message xmlns="http://www.smartertools.com/smarterstats/ServerAdmin.asmx" /> 
 
    <Servers xmlns="http://www.smartertools.com/smarterstats/ServerAdmin.asmx"> 
 
    <ServerInfo> 
 
     <ServerID>1234</ServerID>  
 
     <Name>server1234</Name> 
 
    </ServerInfo> 
 
</Servers> 
 
</ServerInfoArrayResult>

です。ここに私が持っているコードです。しかし、それは何も戻っていない。

ar nsmgr = new XmlNamespaceManager(xDoc.NameTable); 
 
    nsmgr.AddNamespace("a", "http://www.w3.org/2001/XMLSchema-instance"); 
 
    
 

 
    foreach (XmlNode xNode in xDoc.SelectNodes("/Servers/ServerInfo")) 
 
    { 
 
     //Add new row to the output buffer for each employee node in the XML file 
 
     this.ServerInfoBuffer.AddRow(); 
 

 
     //Assign values to the columns. 
 

 
     //Read the 1st attribute of the node Employee 
 
     this.ServerInfoBuffer.ServerID = xNode.ChildNodes[0].InnerText; 
 
     
 
     this.ServerInfoBuffer.ServerName = xNode.ChildNodes[1].InnerText; 
 
     
 
    } 
 
}

+0

コメントなし?あなた自身を説明してください。 – sam

答えて

0

これは動作します。投票ダウン

XmlNamespaceManager nsmgr = new XmlNamespaceManager(xDoc.NameTable); 
 
     nsmgr.AddNamespace("a", "http://www.smartertools.com/smarterstats/ServerAdmin.asmx"); 
 

 
     foreach (XmlNode xNode in xDoc.SelectNodes("//ServerInfoArrayResult/a:Servers/a:ServerInfo", nsmgr))

関連する問題