Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This returns AccessViolationException. There is an element named "account" with the attributes "title" and "uname" set, according to http://msdn.microsoft.com/en-us/library/bb348975(v=vs.110).aspx it should work!?
- // Sample XML content
- // <xml>
- // <settings>
- // <setting name="test" value="value"/>
- // </settings>
- // <accounts>
- // <account title="test" uname="testname"/>
- // </accounts>
- // </xml>
- IEnumerable<XElement> tmpSettings = null;
- IEnumerable<XElement> tmpAccounts = null;
- try
- {
- tmpSettings = from el in XMLData.Elements("setting")
- select el;
- System.Diagnostics.Debug.WriteLine("Node name: " + tmpSettings.FirstOrDefault().Attribute("name").Value);
- System.Diagnostics.Debug.WriteLine("Node value: " + tmpSettings.FirstOrDefault().Attribute("value").Value);
- tmpAccounts = from el in XMLData.Elements("account")
- select el;
- System.Diagnostics.Debug.WriteLine("Node name: " + tmpAccounts.FirstOrDefault().Attribute("title").Value);
- System.Diagnostics.Debug.WriteLine("Node value: " + tmpAccounts.FirstOrDefault().Attribute("uname").Value);
- }catch(Exception ex)
- {
- //do nothing
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement