When sending a request, there is no difference between XHR with the return type of text and xml. The difference is that the callback function processes the returned data using the sample code:
The Code is as follows:
// Callback functionFunction callback (){// Alert (xmlhttp. readyState );// 5. Receive response data// Determine whether the object state is interactive.If (xmlhttp. readyState = 4 ){// Deter
= f.newDocumentBuilder();//builder Document docment = db.parse(new File(fileName));//parese Element el = docment.getDocumentElement();//root domRead(el); } public void domRead(Element currentNode) { if ("struts-config".equals(currentNode.getNodeName())) { config = new StrutsConfig(); } NodeList list = currentNode.getChildNodes(); for (int i = 0; i
(); domRead(e); } if ("form-bean".equals(e.getTagName())) { FormBeanConfig fc = new FormBeanConfig(); Name
Declare, create, create a root node, add a child node of Books, and finally save the document (if the file already exists, update it; if not, create the file ), none of you can understand the definition, creation, and creation of the root node, and addition of the Books sub-node to save the document (if the file already exists, update it; if not, this file is created ).
The code is as follows:
Protected void button#click (object sender, EventArgs e) // create
Sample Code:Copy codeThe Code is as follows:// Callback functionFunction callback (){// Alert (xmlhttp. readyState );// 5. Receive response data// Determine whether the object state is interactive.If (xmlhttp. readyState = 4 ){// Determine whether http interaction is successfulIf (xmlhttp. status = 200 ){// Use responseXML to receive DOM objects of XML Data ObjectsVar domObj = xmlhttp. responseXML;If (domOb
Sample code:
Copy Code code as follows:
callback function
function callback () {
alert (xmlhttp.readystate);
5. Receive response data
Determining the state of an object is an interactive completion
if (xmlhttp.readystate = = 4) {
To determine if HTTP interaction is successful
if (Xmlhttp.status = = 200) {
To receive the DOM object of an XML data object using the Responsexml method
var do
to access an XML file using the DOM, you must link the XML file to an HTML Web page.
Sample code
1. Test.xml
2. test.xsl
The key lies in the use of namespaces xmlns:xsl= "Http://www.w3.org/1999/XSL/Transform" and output plus disable-output-escaping= "yes"
Javascript client conversion [code] lt; html gt; lt; body gt; lt; scriptlanguage quot; javascript quot; gt; LoadXMLvarxmlnewActiveXObject ( quot; microsoft. XMLDOM quot;) xml. asyncfalsexml. load ( quot; cd_catalog.xml quot;) LoadtheXSLvar
Detailed introduction to the sample code of HTML output by XML and XSL conversion (javascript + asp)
The code is a
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.