| |

VerySource

 Forgot password?
 Register
Search
View: 1577|Reply: 9

xmlHttp.responseXML.getElementsByTagName cannot get the value, urgent

[Copy link]

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-2-23 14:00:01
| Show all posts |Read mode
If the requested address is a static XML file, it can be parsed normally, but when the request address is replaced with JSP, the XML content is written out in response.getWriter (). Write in the JSP, it cannot be received by the client. why? The XML content has been printed on the server:
<? xml version = "1.0" encoding = "UTF-8"?> <root> <ShopMember name = "zyaa"> <value> afaf </ value> </ ShopMember> <ShopMember name = "zyaaa"> <value > zyaa_a </ value> </ ShopMember> </ root>
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-5-6 12:45:01
| Show all posts
Checked, it is said that you have to use Servlet, JSP seems not to work, I try it out, depressed.
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-7-23 17:15:01
| Show all posts
Set the contenttype in response, set to application/xml should be no problem
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-7-26 08:15:01
| Show all posts
Your jsp
response.setContentType("text/xml;charset=GBK");
StringBuffer buf = new StringBuffer();
buf.append("<?xml version=\"1.0\" encoding=\"GBK\"?>");
buf.append("<root> ");
while(rs.next())
{
buf.append("<node id='"+rs.getString(1)+"' hasChildren='"+rs.getString(4)+"' pro='"+rs.getString(5)+"'> "+ rs.getString(3)+ "</node>");
}
buf.append(" </root>");
out.print(buf);
Reply

Use magic Report

0

Threads

6

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-8-2 17:00:01
| Show all posts
Set the contenttype in response, set to application/xml should be no problem

This is the main problem. Although you see the print, it may be in html format instead of xml format. Alert ajax.responseXML and ajax.responseText to know what's going on.
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-8-2 20:00:01
| Show all posts
responseXML
still is
responseXml
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 Unknown

Post time: 2020-8-2 21:30:01
| Show all posts
I have also encountered what I said. Cannot get xml when calling jsp page. So consider directly using the class to output xml. You can use ajax to directly access the servlet. If you have used the struts framework, you can directly access the action. Use out.print to output an xml file to memory. This kind of code is available online.
Reply

Use magic Report

0

Threads

6

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-8-2 21:45:01
| Show all posts
responseXML
still is
responseXml
It should be responseXML, you will know it by checking it, it was useless for a while, don't remember.
This has nothing to do with using jsp or servlet.
Reply

Use magic Report

0

Threads

6

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-8-2 22:00:01
| Show all posts
In fact, there is a very simple test method, just use IE to directly access your jsp page, and see if IE is displayed in the xml document format (in this case, the xml document can be contracted) or the normal string displays the jsp page.
If it is displayed in xml document format, then your jsp will be no problem. I think yours is definitely not displayed in xml document format.
Reply

Use magic Report

1

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

 Author| Post time: 2020-8-20 20:30:01
| Show all posts
You can only use Servlet, not jsp, I don't know why.
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list