我在读取 XML 字符串时遇到了问题。在这里,我有以下一个:
<SplitterLayoutDataSet xmlns="http://tempuri.org/SplitterLayoutDataSet.xsd">
<SplitterLayout>
<SplitterName>mainSplitContainerControl</SplitterName>
<SplitterPosition>0.2213375796178344</SplitterPosition>
</SplitterLayout>
</SplitterLayoutDataSet>
所以,我想用<SplitterName>
以下代码读取标签:
XmlElement rootElement = doc.DocumentElement;
rootElement.RemoveAllAttributes();
if (rootElement != null)
{
foreach (KeyValuePair<Control, object> key in SaveLayoutControls)
{
Control c = key.Key;
XmlElement el = rootElement.SelectSingleNode("SplitterName") as XmlElement;
if (el != null)
{
if (c is GridControl)
SetGridLayout(el, c as GridControl);
else if (c is SplitContainerControl)
SetSplitContainerLayout(el, c as SplitContainerControl);
else if (c is TreeList)
SetTreeListLayout(el, c as TreeList);
else if (c is CollapsibleSplitter)
SetCollapsibleSplitterLayout(el, c as CollapsibleSplitter);
else if (c is Splitter)
SetSplitterLayout(el, c as Splitter);
}
}
}
我想读取“el”字段,但它返回 NULL 值。有什么想法可以解决这个问题吗?因为我尝试了很多方法都没有结果。谢谢