Posts

Showing posts from February, 2015

Validate XML using XSD

Validate XML against XSD XSD(XML Schema Definition) contains set of grammatical rules, Which can be used to validate a given xml. Lets consider a sample XML file. <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="Projects.xsl"?> <catalog>     <model name="s3">         <network>GSM</network>         <launch>2012-10-12</launch>         <os>Android</os>         <version>4.1</version>         <cpu>dual-core</cpu>         <weight>111.5</weight>         <sim>mini-sim</sim>     </model>     <model name="s5">         <network>GSM</network>         <launch>2013-10-12</launch>         <os>Android</os>         <version>4.4</version>         <cpu>quard-core</cpu>         <weight>140.5</weight>       

Building an XML Structure and Parse the XML file

Image
Through this article, let me create a simple XML file and parse it using a DOM Parser. First of all let's create a sample XML file with some elements and attributes. Build an XML fil e <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="Projects.xsl"?> <catalog>     <model name="s3">         <network>GSM</network>         <launch>2012-10-12</launch>         <os>Android</os>         <version>4.1</version>         <cpu>dual-core</cpu>         <weight>111.5</weight>         <sim>mini-sim</sim>     </model>     <model name="s5">         <network>GSM</network>         <launch>2013-10-12</launch>         <os>Android</os>         <version>4.4</version>         <cpu>quard-core</cpu>         <weight>14