In the servlet, you can directly use
1 string[] Property=request.getparametervalues ("property"); // Properties
To get the property value of the same ID. But in JS, it won't work. We only get the elements in the way of finding nodes. With this approach, it is already transparent to us whether the ID is the same.
1property[0]=$ ("#property"). Val ();2relation[0]=$ ("#relation"). Val ();3propertyvalue[0]=$ ("#wordvalue"). Val ();4node=$ ("#property"). Parent (). Parent (). Next ();5 while(node.length>0){6Property[i]=node.children (": First"). Children (": First")). Val ();7Relation[i]=node.children (": First"). Next (). Children (": First"). Val ();8Propertyvalue[i]=node.children (": First"). Next (). Next (). Children (": First"). Val ();9Node=Node.next ();Teni++; One}
In the above example, set three array variables:
1 var property=New Array (); 2 var relation=New Array (); 3 var propertyvalue=New Array ();
where parent () returns the node's parents (only one node is returned).
Children () returns all the child nodes of the current node, if you use Property=node.children (). val (); error. If you are using children (": First"), you will be returned with the second child node.
Next () returns the next sibling node of the current node.
Node.length>0 is used to determine whether the current node exists.
This allows you to traverse all the desired nodes.
1 $.post ("Test/contextservlet", {property:property,relation:relation,2 Propertyvalue:propertyvalue},function (data) {autonode.html (data);});
The above uses JQ to pass values to the servlet.
JavaScript gets elements of the same ID