0
Oops, how are you? I’m seizing C# on my own (after being initiated into python programming at the university).
I’m trying to create 1 software that reads an XML file and wanted to split the file the same way as the following image.
In this case I wanted to "count" for each larger "Customer" knot. So that in the future if I want to print the first, second, third. (Would be the choice of the user).
Well I’m trying to do this using "Arquivoxml". Descendent("Customer").
IEnumerable<XElement> items =
from el in pu2.Descendants("Customer")
select el;
foreach (XElement el in items)
{
MessageBox.Show (el.ToString());
}
The point is that I am trying in every way to transform/acquire the values of the variable (Xelement) into INT, but I cannot :(.
I was wondering if I’m using "Ienumerable" correctly, if I should use "List". I have thought about transforming into text and using "Readalllines" to pick up the string files. However I believe there is a better way to do this.
I saw recently that maybe I should use Icollection or Ilist.
Anyway who can help me :) or even talk a way, or where I’m going wrong, I would be extremely grateful.
If you want to browse the collection based on an index, use the good old
for
and notforeach
. AboutIEnumerable
xIList
, I’m not sure why C# isn’t my thing, research what each one represents and choose the right one.ICollection
should not be because it should represent collections that may not necessarily have first item, second, third, etc. ordering such as sets (sets) or similar, which have no defined order.– Piovezan
what you mean by accounting?
items.Count()
???– Leandro Angelo
@Leandroangelo, exact, in the case I wanted when I typed in the console: "1". He printed the information of {1} (in the image), and so on. I’m trying to use the string[](turning the xml into text) (or Object) and trying to allocate each Node <Customer>. Only I’m trying hard to do it in an automated way.
– Cleverton Teixeira
I have been researching believe that the ideal serial use ilist.item[int32], I will see here more about.
– Cleverton Teixeira
What do you mean by "automated way"?
– Leandro Angelo