我有400多條數據記錄在這裏面格式:C#XML解析成陣列
<rs:data>
<z:row ows_ID='360' ows_LinkTitle='GEI Survey data to Sharepoint' ows_Project_x0020_Priority='0' ows_AssignedTo='615;#Jeremy, Ron' ows_Status='In Progress' ows_Priority='(2) Normal' ows_DueDate='2012-04-27 00:00:00' ows_PercentComplete='0.700000000000000' ows_Modified='2012-04-30 10:44:15' ows_Alignment='TSS Delivery Mgmt' ows_SME='44;#Lewis, Clark' />
<z:row ows_ID='378' ows_LinkTitle='Create back end and environment to support User demographic reporting' ows_Project_x0020_Priority='0' ows_AssignedTo='615;#Sam, Johns' ows_Status='In Progress' ows_Priority='(2) Normal' ows_DueDate='2012-05-11 00:00:00' ows_PercentComplete='0.800000000000000' ows_Modified='2012-05-09 13:50:17' ows_Alignment='Team Internal' ows_SME='7;#CORP\sscer;#9;#CORP\vreer' />
<z:row ows_ID='249' ows_LinkTitle='Training Material to Muti Media' ows_AssignedTo='620;#Jenkins, Kristen' ows_Status='Not Started' ows_Priority='(2) Normal' ows_DueDate='2012-08-10 00:00:00' ows_PercentComplete='0' ows_Modified='2012-05-16 11:20:29' ows_Alignment='Diver Support' ows_SME='1;#CORP\vsswer;#7;#CORP\adder' />
</rs:data>
如何創建indivisual數組存儲ows_ID,ows_LinkTitle值annd等等?
的foreach(在activeItemData System.Xml.XmlNode節點)
{ if (node.Name == "rs:data") { for (int i = 0; i < node.ChildNodes.Count; i++) { if (node.ChildNodes[i].Name == "z:row") { string [] resultTitle; resultTitle = (node.ChildNodes[i].Attributes["ows_Title"].Value).ToArray(); Console.ReadLine(); } } } }
它投擲的錯誤錯誤無法隱式轉換類型 '字符串[]' 在resultTitle '的char []'。我如何糾正它?謝謝。
我做
char[] resultTitle;
resultTitle = (node.ChildNodes[i].Attributes ["ows_Title"].Value).ToArray();
string s = new string(resultTitle);
Console.ReadLine();
我怎麼做它[ 「ows_Title」]的所有值。 ?謝謝。
結束了,我們不知道什麼'rs'或'z'平均(不是被某些XML命名空間等)。什麼是你真正的XML,究竟是什麼想擺脫它? –
L.B-真正的xml是從Web引用返回到SharePoint列表的數據。我想獲得屬性的所有值的數組,如[ows_id],[ows_Title]等在非獨立數組中,以便我可以將它們作爲參數傳遞給我的SQL表中插入這些值。如果你想看看它看起來像什麼 - http://stackoverflow.com/questions/10739535/insert-xml-attribute-values-in-a-sql-table – Nemo
不,謝謝我不能說我是對看到你的問題後的外觀很感興趣的是'char []':) –