2
I want to create an application for android with C# using Xamarin, it takes in a "database" xml some information and puts it on the screen, but I’m not able to manipulate xml.
I need to search the "symbol" in xml and if I find to take the information and put in variables, but I’m not getting:
Example of xml:
<?xml version="1.0" encoding="utf-8" ?>
<Itens>
<tb>
<simbolo>G</simbolo>
<nAtomic>56</nAtomic>
<valencia>5</valencia>
</tb>
<tb>
<simbolo>Ga</simbolo>
<nAtomic>565</nAtomic>
<valencia>55</valencia>
</tb>
</Itens>
When I use the StreamReader
:
StreamReader strm = new StreamReader ("Db.xml");
XDocument xd = XDocument.Load(strm); //......
Gives the following error:
Error CS0246: The type or namespace name 'Streamreader' could not be found (are you Missing a using Directive or an Assembly Reference? ) (CS0246)
I thought I’d use the XmlTextReader
but I don’t know how to do it, someone can help me?
add using System.IO; at the beginning of the file.
– Tony
now the error is this: Error CS0246: The type or namespace name 'Xdocument' could not be found (are you Missing a using Directive or an Assembly Reference? ) (CS0246)
– mrlucasrib
Can you put your full code in the question, please?
– Leonel Sanches da Silva
@Luke makes reference to
System.Xml.Linq
in your project and addusing System.Xml.Linq
in his.cs
.– Omni
@Lucas who creates XML? The schema was set by you?
– Omni
Take a look at that question, and I hope it helps you get what you need. http://answall.com/questions/13087/o-que%C3%A9-serializa%C3%A7%C3%A3o-when-to-use-how-to-implement-no-c
– johhny
add using System.xml.Linq; at the beginning of the file.
– Tony
Thank you all, but... anyone knows of any tutorial that can handle xml files with the Xdocument? c.c class
– mrlucasrib