我继承了一些旧代码,需要转换为Umbraco API中的最新架构。
private void GenerateDDL()
{
int currentId = Int32.Parse(umbraco.library.GetXmlNodeCurrent().Current.SelectSingleNode("@id").Value);
string xpath = string.Format("//node[@id={0}]/descendant::node[@nodeTypeAlias='FormDropdownOption']", currentId);
XPathNodeIterator xml = umbraco.library.GetXmlNodeByXPath(xpath);
while (xml.MoveNext())
{
//hsEmailList.Add(xml.Current.SelectSingleNode("./data[@alias='Text']").Value.ToString(), xml.Current.SelectSingleNode("./data[@alias='Value']").Value.ToString());
hsEmailList.Add(xml.Current.SelectSingleNode("Text").Value.ToString(), xml.Current.SelectSingleNode("Value").Value.ToString());
}
foreach (DictionaryEntry de in hsEmailList)
{
ListItem list = new ListItem();
list.Text = de.Key.ToString();
list.Value = de.Value.ToString();
ddlMemberName.Items.Add(list);
}
}
我需要从注释代码中将./data [@alias ='Text']更改为更新的架构。有什么想法吗?
答案 0 :(得分:0)
变化:
hsEmailList.Add(xml.Current.SelectSingleNode("./data[@alias='Text']").Value.ToString(), xml.Current.SelectSingleNode("./data[@alias='Value']").Value.ToString());
为:
hsEmailList.Add(xml.Current.SelectSingleNode("./Text").Value.ToString(), xml.Current.SelectSingleNode("./Value").Value.ToString());