jQuery小写xml元素名称 [英] jQuery lowercasing xml element names
本文介绍了jQuery小写xml元素名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
jQuery正在小写所有name
属性值.
我有这样的HTML表单:
jQuery is lowercasing all name
attribute values.
I have HTML form in like this:
<input type="text" name="firstName">
<input type="text" name="lastName">
<input type="text" name="amountForName">
尝试读取它并创建具有其值的xml.
jQuery
Trying to read it and create a xml with its value.
jQuery
$(section).find('input').each(function(i, field) {
console.log($(field).attr('name'));//prints 'firstName'
var $fieldName = $.createElement($(field).attr('name'));
$fieldName.text($(field).val());
$.createElement = function(name)
{
console.log('Creating Element '+name); //prints 'firstName'
return $('<'+ name +' />');
}
但是xml元素松散了,我明白了
But the xml elements loose came casing and I get
<firstname>himanshu</firstname><lastname>yadav</lastname>
如何为节点名称保留骆驼套?
How can I retain camel casing for node names?
推荐答案
在这里检查:
xmlDoc = document.implementation.createDocument("", "", null);
root = xmlDoc.createElement("description");
xmlDoc.appendChild(root);
alert((new XMLSerializer()).serializeToString(xmlDoc));
这是从这里: https://stackoverflow.com/a/1752772/2391022
此外,请在此处查看: http://www.w3schools.com/dom/dom_nodes_create.asp
Also, check out here: http://www.w3schools.com/dom/dom_nodes_create.asp
这篇关于jQuery小写xml元素名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文