XML always provide better solution compare to other technique, toady we are focusing on how to generate custom validation string by use of Sql server. Sometimes you need to create XML string ( with it’s nodes and value structure ) in asp .net , i think it is quite easy task for you and you will get more then thousand tutorial of it that teach you how to generate such kind of string but when it is come on Sql server ,it is quite complex as my point of view , so here i am going to share something interesting with you . I hope you will like it .
What is XML ?
XML (Extensible Markup Language) is a flexible way to create common information formats and share both the format and the data on the World Wide Web, intranets, and elsewhere. For example, computer makers might agree on a standard or common way to describe the information about a computer product (processor speed, memory size, and so forth) and then describe the product information format with XML. Such a standard way of describing data would enable a user to send an intelligent agent (a program) to each computer maker’s Web site, gather data, and then make a valid comparison. XML can be used by any individual or group of individuals or companies that wants to share information in a consistent way.
Advantages of XML
- It is a simultaneously human- and machine-readable format.
- It supports Unicode, allowing almost any information in any written human language to be communicated.
- It can represent the most general computer science data structures: records, lists and trees.
- Its self-documenting format describes structure and field names as well as specific values.
- The strict syntax and parsing requirements make the necessary parsing algorithms extremely simple, efficient, and consistent.
- XML is heavily used as a format for document storage and processing, both online and offline.
- It is based on international standards.
- It allows validation using schema languages such as XSD and Schematron, which makes effective unit-testing, firewalls, acceptance testing, contractual specification and software construction easier.
- The hierarchical structure is suitable for most (but not all) types of documents.
- It manifests as plain text files, which are less restrictive than other proprietary document formats.
- It is platform-independent, thus relatively immune to changes in technology.
- Forward and backward compatibility are relatively easy to maintain despite changes in DTD or Schema.
- Its predecessor, SGML, has been in use since 1986, so there is extensive experience and software available.
Disadvantages of XML
- XML syntax is redundant or large relative to binary representations of similar data.
- The redundancy may affect application efficiency through higher storage, transmission and processing costs.
- XML syntax is too verbose relative to other alternative ‘text-based’ data transmission formats.
- No intrinsic data type support: XML provides no specific notion of “integer”, “string”, “boolean”, “date”, and so on.
- The hierarchical model for representation is limited in comparison to the relational model or an object oriented graph.
- Expressing overlapping (non-hierarchical) node relationships requires extra effort.
- XML namespaces are problematic to use and namespace support can be difficult to correctly implement in an XML parser.
- XML is commonly depicted as “self-documenting” but this depiction ignores critical ambiguities.
If you want to create XML string by using store producer in sql server at that time this tutorial might be help you.Just write the below query into your sql server and customize it according to your requirement, after that execute it for the output.
–First Node Range validation
SELECT ( SELECT ‘Range must be 0 to 5’ AS ErrorMessage,
‘1’ AS MaximumValue,
‘100’ AS MinimumValue,
‘Integer’ AS Type
( SELECT ‘Are you Sure !’ AS AlertMessage,
‘7’ AS AlertValue
FOR XML PATH(”),
If everything gone correct then you will get one xml string with node and its value.
<ErrorMessage>Range must be 0 to 5</ErrorMessage>
<AlertMessage>Are you Sure !</AlertMessage>
If you have any question then please feel free to ask me way comment . 🙂 🙂
Get Free Weekly Updates
Get Weekly Email on latest blogging Tips & news from Stackbuddy.