RULES FOR XML SYNTAX DECLARATION
- If document contains a XML declaration then it must be first statement of the document.
- XML declaration is case – sensitive, where document begins with <?xml>. “xml” is in lower case.
- An HTTP protocol can override the value of encoding that you put in the XML declaration.
<?xml version="1.0" encoding="UTF-8"?>
SYNTAX RULES FOR ELEMENTS AND TAGS
Element Syntax: every XML-element must be closed either with begin or with finish components as shown below:
or just by this technique:
Nested elements: An XML element can contain other XML- elements as its child, but the children elements must not overlap it parent element. i.e., an end tag of an element must have the same tag name as that of the most recent unmatched start tag.
example for incorrect nested tags:
example for correct nested tags:
Root element: An XML document must have and can have only one root element. For example, following example is not a correct XML document, because both the a and b elements occur at the top level without a root element:
The correct form of XML document is:
Case sensitivity: The tag names of XML-elements are case-sensitive. This means that the name of the starting and the ending elements should be exactly in the same case.
For example <Syntax> is different from <syntax>.
XML refers to Extensible Markup Language. It is used to store and to transport data.
XML SYNTAX DOESN’T HAVE PREDEFINED TAGS
The XML language do not have any predefined tags.
The tags in the example below(student, course, etc) are not defined in any XML standard. These tags are “Created” by the author of the XML document.
HTML works with predefined tags like <h1>, <p>, <table>, etc.
With XML, the developer must define both the document structure and the tags. And each tag must have its starting and ending tags.
The above example explain how we could arrange the element tags to maintain the data through XML.
In the above example, It explain that a college may have multiple courses and each course have their subjects.
This is how we write XML document.
The Elements in XML document may contain other elements or data or nothing.
In the above example first tag also refer as element named as root contains two sub elements named child1 and child2.
And child1 contain a data value which is “syntax definition” where as element named as child2 is empty
A Prolog defines the XML version and the character encoding. However it is completely optional but if used it must be place at top of document.
<?xml version="1.0" encoding="UTF-8"?>
PHP Script Basics
PHP is a scripting language which is used for developing dynamic webpages. Php script and html code can share same file for the development. So to differentiate php code from other stuff. There are four ways to define syntax :
1. The Most common ways is to use Canonical PHP tags to mark where is php code
<?php /*place your php code here*/ ?>
2. Short-Open tags is the shortest option one can use, but for using this, one must :
- Choose the –enable-short-tags configuration option when you’re building PHP script.
- Set the short_open_tag setting in your php.ini file to on. This option must be disabled to parse XML with PHP because the same syntax is used for XML tags.
<? /* Your php code here */ ?>
3. ASP style tags are just like actual Active Server Pages tags. And can be used after some configuration in php.ini file.
<% your php code %>
The file which contain php code should be saved with .php or any other compatible extension.
It starts with <!DOCTYPE html > //It’s used for rendering purpose.
All elements must be written inside opening <html> and closing </html> tags.
Visible portion of markup comes within <body>…..</body> tags.
<title> MY TITLE </title>
//place your content here
HTML HEADINGS SYNTAX
<h1>,<h2>,<h3>,<h4>,<h5>,<h6> tags can be used to represent different text size.
It used for heading, sub-heading and so on.
Paragraph can be defined with <p>…</p> tags
Anchor tags can be used to generate hyperlinks <a>
Images can be added with <img> tag. It’s Syntax is explained in below example.
<p>This is our sample paragraph</p>
<a href="http://www.syntaxdefinItion.com">link text</a>
here, the target location is added to the href attribute.
Anything at place of link text will work as hyperlink on frontend.
//HTML images are defined with the <img> tag.
<img src="logo.jpg" alt="mywebsite.com" width="104" height="142">
/*The source file (src), alternative text (alt), and size (width and height) are provided as attributes:*/
Here we will try to help every individual or professional who is facing difficulty in their education or profession related to coding.
So, We request all our members on-board to help other fellow members with the information you have.