XElement service = doc.Element("Ids");
service.Add(new XElement("ID", idulong.ToString(),new XElement("Succesfull",1)));
Example output
<ID>
9223372036854775808
<Succesfull>1</Succesfull>
</ID>`
I want
<Ids Userid= 9223372036854775808>
<Succesfull>1</Succesfull>
</Ids>
The Id is different for each user.I want check users with id.
Look at your code just changed to show the level of nesting:
service.Add(new XElement("ID",
idulong.ToString(),
new XElement("Succesfull",
1)));
In other words, the Succesfull
element is within the ID
element constructor call.
You just want to add two separate elements, either with two separate calls to service.Add
:
service.Add(new XElement("ID", idulong.ToString());
service.Add(new XElement("Succesfull", 1));
or in one call to Add
, taking multiple elements:
service.Add(new XElement("ID", idulong.ToString()),
new XElement("Succesfull", 1));
You don't need to call ToString
, by the way - it's fine to write:
service.Add(new XElement("ID", idulong),
new XElement("Succesfull", 1));
(You might want to use Successful
or just Success
instead of Succesfull
though...)
See more on this question at Stackoverflow