簡體   English   中英

xmlhttp send從XML文件發送單個對象

[英]xmlhttp send to send a single object from a XML file

我目前正在使用xmlhttp將某些內容發送回PUT到Web服務上:

我的XML:

<collection>
 <beanRepresentation>
  <beanRepId>1323</beanRepId>
  <beanRepName>john</beanRepName>
 </beanRepresentation>

  ...more <beanRepresentations> ..

</collection>

我提取此XML,並通過HTML頁面進行一些更改。 現在,我想使用PUT更新對beanRepresenetation所做的更改。

我不想更新整個XML,而只想更新更改過的單個對象。我這樣做如下:

xmlhttp.open("PUT","http://localhost:8080/rest/beanRepresentation",
                                    false);
xmlhttp.setRequestHeader("Content-type","application/xml");
xmlhttp.send((xmlDoc.getElementsByTagName("beanRepresentation")[0]));

螢火蟲說:

PUT http://localhost:8080/rest/beanRepresentation 400 Bad Request

源顯示這是我發送的內容:

[object Element]

這是問題,為什么我不發送回去:

<collection>
 <beanRepresentation>
  <beanRepId>1323</beanRepId>
  <beanRepName>Updated Name</beanRepName>
 </beanRepresentation>

</collection>

?? 我需要它像上述格式一樣將其放回去,而不是“ [Object Element] ”。

弄清楚了:

xmlhttp.send((new XMLSerializer()).serializeToString(xmlDoc.getElementsByTagName("beanRepresentation")[i]));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM