Adding a schema reference

If you work with XML, you should also work with XML Schema. The XML Schema specifies the layout of the XML document. It can also be used to specify data types for content embedded in the document. XML Schemas make working with XML more predictable, since it is possible to validate XML against it and perform certain processes automatically. XML Schemas separate elements and their attributes using namespaces. These are typically URLs. In XML, the namespace of an element and its children are defined by using the xmlns attribute. Typically, for short XML responses, we only need to set it on the root element. In our case, we will use a local schema and define the namespace to be the URL of the sensor itself, with /schema.xsd appended to it:

string SchemaUrl = Request.Header.GetURL(); 
int i = SchemaUrl.IndexOf("/Momentary"); 
SchemaUrl = SchemaUrl.Substring(0, i) + "/schema.xsd"; 
 
Response.Write("<Momentary timestamp='"); 
Response.Write(DateTime.Now.ToUniversalTime(). 
   ToString("yyyy-MM-ddTHH:mm:ss.fffZ")); 
Response.Write("' xmlns='"); 
Response.Write(SchemaUrl); 
Response.Write("'>"); 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.225.11.98