Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/362.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript xml文档和查找_Javascript_Xml - Fatal编程技术网

Javascript xml文档和查找

Javascript xml文档和查找,javascript,xml,Javascript,Xml,假设我有以下非常简单的XML片段: <assignmentOptions> <MessageCharacterLimit value="4000" type="integer"></MessageCharacterLimit> </assignmentOptions> <options> <MessageCharacterLimit value1="1000" type="integer"></Mess

假设我有以下非常简单的XML片段:

<assignmentOptions>
    <MessageCharacterLimit value="4000" type="integer"></MessageCharacterLimit>
</assignmentOptions>
<options>
    <MessageCharacterLimit value1="1000" type="integer"></MessageCharacterLimit>
    <MessageCharacterLimit value2="2000" type="integer"></MessageCharacterLimit>
</options>

如何在
下找到所有MessageCharacterLimit? MessageCharacterLimit不是唯一的,但options/MessageCharacterLimit是唯一的

谢谢

您可以使用:

var a=document.querySelectorAll('options>MessageCharacterLimit');
console.log(a)

只是好奇而已。如果我这样做:$(a).each(函数(){……});然后对于只有一个元素的a,每个函数调用两次。有什么想法吗?