How to parse a xaml file/string

前端 未结 1 537
忘了有多久
忘了有多久 2021-01-25 12:17

I\'m reading an xaml file using XamlReader() and it has of course elements and attributes such as:



        
相关标签:
1条回答
  • 2021-01-25 13:00

    The MSDN docs show using an XmlReader as input to XamlReader

    // Load the button
    StringReader stringReader = new StringReader(savedButton);
    XmlReader xmlReader = XmlReader.Create(stringReader);
    Button readerLoadButton = (Button)XamlReader.Load(xmlReader);
    

    http://msdn.microsoft.com/en-us/library/system.windows.markup.xamlreader.aspx

    You could just use the XmlReader to grab attributes.

    http://msdn.microsoft.com/en-us/library/cc189056%28VS.95%29.aspx

    You would use XmlNodeType.Attribute in the switch statement shown in the MSDN example, after first noting the node you're in in the XmlNodeType.Element case.

    0 讨论(0)
提交回复
热议问题