Показать сообщение отдельно
  #7 (permalink)  
Старый 22.09.2015, 21:56
Аватар для рони
Профессор
Отправить личное сообщение для рони Посмотреть профиль Найти все сообщения от рони
 
Регистрация: 27.05.2010
Сообщений: 33,070

abrasum,
<!DOCTYPE HTML>

<html>

<head>
  <title>Untitled</title>
  <meta charset="utf-8">
  <style type="text/css">
  </style>
  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
  <script>
     $(function(){
 var s = $("root");
       alert(s.children().length) //Получить количество детей 1-го уровня документа (в данном примере это будет: 7)
  var a = s.children().filter(function() {
    return this.tagName.toLowerCase() != "other"
})
      alert(a.length)  // 6
});

  </script>
</head>

<body>

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<root>
	<item>item1.</item>
	<item>item2.</item>
	<item>bla-bla-bla.</item>
	<item>hello world</item>
	<other>
		<item>Other item1.</item>
		<item>Other item2.</item>
	</other>
	<item>Also other</item>
	<item>Also other</item>
</root>



</body>

</html>
Ответить с цитированием