Introduction to XML Commands
XML means Extensible markup language. It is used for storing and transporting the data. It is markup language like HTML. XML is mainly used for web development purpose. XML Commands cannot be used for data to display to the end user but it is the separation between the data and presentation. XML data can be stored in XML files which has extensions like .xml. As XML separates the data from HTML, which helps you in updating the content of an HTML page. It mainly encoded in both human and machine-readable format.
Basic XML Commands
- XML declaration
<?xml version=”1.0″ encoding=”UTF-8″?>
- Element tag: Element names are case-sensitive and it should start with letter or underscore. It cannot contain spaces but they can contain letter, digits, underscore.
- Root tag: It can be only one in XML document or XML file.
Syntax: <root> <x> </x> </root>
Example: <Name> <<firstName></firstName> </Name>
- Add: Include the node to XML Commands.
Example: <add afterID=” system”> </add>
- Remove: Used for removing a node the specific id from resulting XML.
Example: <remove node=” system” />
- SET: This changes the parent element in resulting XML
Example: <set prop1=”name” value=” TOM” />
- Setattribute: Changes the set of attributes for the parent xml in resulting XML.
Example: <setAttributes attr1=”name” attr2=”value” />
- Empty tag: Command is used to show the element which is not having content.
Example: <hr> </hr> or <hr />
- Namespace: This is being used to avoid the conflict, start the name using a prefix.
Syntax / example: <k: table> <k: name> JOHN </k: name> </k: table>
<j: table> <j: name> WRIGHT </j: name> </j: table>
- XLink: This is used to create hyperlinks with in XML documents.
Syntax: <page xmlns: xlink= http://www.ggogle.com”> </page>
Advanced XML Commands
- XML DTD: This is the file which has DOCTYPE declaration in XML Commands file. It is used for XML to make it well managed and valid for the XML.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE abc SYSTEM "ABC.dtd">
- XML schema: This XML commands is used as XS in the XML file. It also defines the structure of the XML file or the document. It is valid against the schema to be well-formed and valid.
<xs:element name="name" type="xs:string"/>
<xs:element name="location" type="xs:string"/>
<xs:element name="heading" type="xs:string"/>
<xs:element name="body" type="xs:string"/>
- Xpath: This expression is used to select the root element like /abc and it selects the other elements based on the tag provided like /abc/1.
- To format the XML document XSL-FO language is being used, it is the set of language that can transform XML into XHTML, filter, and sort XML data. It helps in displaying the negative number, and XML data output in form of pictures and paper.
The XML file looks like as below:
<?xml version="1.0" encoding="UTF-*"?>
<?xml-stylesheet type="text/xsl" href="simple.xsl"?>
- XML can be used for programming as well, to parse the XML based on java programming document object model is used. It also called as DOM compliant parser. There are many other parsers also available for the same.
- XML is also being used with CSS, the same way HTML has been used with CSS. Need to provide the below text in XML file
<?xml-stylesheet type=”text/css” href=”cd catalog.css”?>
- XML files can be viewed in internet explorer or other browsers as the HTML pages are viewed while browsing.
Tips and Tricks to use XML Commands
- Identify the elements and write it similar format across all the XML file
- To be price while writing a name for tags as they are case sensitive.
- Syntax should be well managed.
- Always try to use different names otherwise conflicts make the XML file unreadable.
- The definition of elements and syntax should be clear.
XML commands are easy to write and use for a different application while storing and transporting the data. It is lightweight and mainly used in a configuration file of almost in each tool. It is very easy to learn and all the things are mainly covered in tags. XML validator is being used to validate the XML to manage the format and output of the file or resulting XML.
This has been a guide to XML Commands. Here we have discussed basic XML Commands and some Advance XML commands. You may also look at the following article to learn more –