0

how can declare type of node in XmlElement in XML ?

for example i wanna "age" will be Int32 and gender Boolean. how can do this ?

    XmlElement age = doc.CreateElement("Age");
    XmlElement gender = doc.CreateElement("Gender");
user3374618
  • 73
  • 1
  • 11
  • checkout `Jon Skeets` post http://stackoverflow.com/questions/3405284/how-to-add-attributes-to-xml-using-xmldocument-in-c-sharp-net-cf-3-5 – MethodMan Apr 14 '14 at 19:43

2 Answers2

0

XML is all about text you cannot do such thing in XML if you want to force the check of the value type you have to use XSD in order to validate your XML

this article show how you can do this

C# - XML Schema Validator

BRAHIM Kamel
  • 13,492
  • 1
  • 36
  • 47
0

You cannot specify what type the element has to be when creating it. You need to define a XML schema which will hold the information about what is allowed by your XML and what is not.

Here is a guide for XSD by microsoft: http://msdn.microsoft.com/en-us/magazine/cc302086.aspx

Kristian Barrett
  • 3,574
  • 2
  • 26
  • 40