web and it technology
web and it technology
Assignment Questions
2) Explain the html DOM. How it is used to design the web page.
Ans. The HTML DOM (Document Object Model) is a programming interface for
HTML documents that de nes the logical structure of the document and the way it
can be accessed and manipulated. The DOM represents the page as a tree structure
where each node is an object representing a part of the document (like an element,
attribute, or piece of text).
How the DOM Is Used to Design Web Pages:
1. Dynamic Content:
◦ You can modify the content of a page after it has loaded without refreshing the
page.
2. Styling:
• The DOM allows you to manipulate the CSS styles of elements. Using style properties in
JavaScript, you can change element sizes, colors, visibility, etc.
fi
fi
fi
fi
fi
3. Event Handling:
• The DOM is crucial for handling events like mouse clicks, form submissions, or keyboard
input.
4. Form Validation:
• The DOM can help in form validation. You can check if a form eld is lled correctly before
allowing the form to be submitted.
5. Creating Elements Dynamically:
• You can dynamically create new elements and add them to the document.
<EducationalDetails>
<Institution>
fi
fi
fi
fi
fl
fi
<Name>Spring eld University</Name>
<Degree>Bachelor of Science in Computer Science</Degree>
<StartYear>2016</StartYear>
<EndYear>2020</EndYear>
<GPA>3.8</GPA>
</Institution>
<Institution>
<Name>Spring eld High School</Name>
<Degree>High School Diploma</Degree>
<StartYear>2012</StartYear>
<EndYear>2016</EndYear>
<GPA>3.9</GPA>
</Institution>
</EducationalDetails>
</StudentInformation>
An element declaration de nes an XML element and speci es the data type and constraints
on its content. These declarations specify the properties of the elements, including:
<StudentInformation>
<FirstName>John</FirstName>
<LastName>Doe</LastName>
fi
fi
fi
fi
fi
fi
fi
fi
fi
<Age>22</Age>
</StudentInformation>
The DOM parser reads the entire XML document and loads it into memory as a
hierarchical (tree-like) structure. It represents the XML document as a tree of nodes,
where each node corresponds to an element in the document. The program can then
traverse, manipulate, or query the tree structure.DOM parsers are great for small
documents where you need random access and manipulation.
The SAX parser reads the XML document sequentially, element by element. It
doesn't load the entire document into memory. Instead, it triggers events as it
encounters different parts of the XML (start of an element, end of an element, text
data, etc.).SAX parsers are ef cient for large documents but are more complex and
only suitable for reading.
fi
fi
8) Explain XMLHttpRequest Object methods and Properties.
Ans.The XMLHttpRequest object is a key component in JavaScript used for
making asynchronous HTTP requests to servers. It allows you to send and
receive data from a server without refreshing the entire web page, enabling
dynamic web applications. Below are the main methods and properties of the
XMLHttpRequest object.
Properties of XMLHttpRequest
1. readyState
◦ Represents the current state of the request.
◦ Possible values:
▪ 0: UNSENT - The request has been initialized but not yet sent.
▪ 1: OPENED - The request has been opened but not sent.
▪ 2: HEADERS_RECEIVED - The request has been sent, and the response
headers have been received.
▪ 3: LOADING - The response is being received (data is being downloaded).
▪ 4: DONE - The request is complete, and the response is fully received.
2. status
◦ Contains the HTTP status code returned by the server (e.g., 200 for OK, 404 for
Not Found).
◦ A status of 0 may indicate that the request was not completed or failed.
3. statusText
◦ Contains the status message corresponding to the status code (e.g., "OK" for status
200).
4. responseText
◦ Contains the response data as a string. This property is populated after the request
has completed (i.e., readyState is 4).
5. responseXML
◦ Contains the response data as an XML document, which is available when the
response content type is XML.
6. timeout
◦ Represents the timeout value (in milliseconds) for the request. If the request takes
longer than this time, it will be aborted.
7. withCredentials
◦ A boolean property that indicates whether the request should include credentials (like
cookies) in cross-origin requests.
Methods of XMLHttpRequest
3. setRequestHeader(header, value)
9) Differentiate between:
a) HTML and DHTML.
b) XML Schema De nition and Document Type De nition
Ans.
HTML DHTML
Consists solely of HTML tags Combines HTML for structure, CSS for
Components and elements. design and JavaScript for interactivity
Static, i.e., displays the same Dynamic, i.e., content can be changed in
Nature content every time the page is response to user action without reloading the
loaded. page.
SGML syntax is used for DTD. XML is used for writing XSD.
XLinks
ii) AJAX
iii) PHP
iv) ASP