這裏是我的代碼解析值.NET C#
String MyXml = "<av:Button Name="btn_1" Width="80" Height="25" x:Uid="btn_1" av:Canvas.Left="168.1" av:Canvas.Top="95.1" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">My Button Content</av:Button>";
XmlNamespaceManager mngr = new XmlNamespaceManager(new NameTable());
mngr.AddNamespace("av", "http://www.w3.org/2001/XMLSchema-instance");
XmlParserContext parserContext = new XmlParserContext(null, mngr, null, XmlSpace.None);
XmlTextReader txtReader = new XmlTextReader(MyXml, XmlNodeType.Element, parserContext);
var doc = XElement.Load(txtReader);
var name = doc.Attribute("Name").Value;
var width = doc.Attribute("Width").Value;
var Uid = doc.Attribute("Uid").Value; // Not Working
我無法獲得,因爲不同的命名空間可能的的Uid,同樣適用於AV:Canvas.Top。
如何獲取這些屬性?
-TIA