צפיות
תשובות
createElementNS Method לא ברור לי מה זה בדיוק
היי,
הגעתי לקוד שאני צריך ללמוד אותו בכתובת.
http://www.w3schools.com/dom/met_document_createelementns.asp
לא הצלחתי להבין שתי שורות בקוד
1 – newel=xmlDoc.createElementNS("p","edition");
2 – document.write(z[i].namespaceURI);
מתוך הקוד הבא:
<html>
<head>
<script type="text/javascript" src="loadxmldoc.js">
</script>
</head>
<body>
<script type="text/javascript">
xmlDoc=loadXMLDoc("books.xml");
x=xmlDoc.getElementsByTagName('book');
var newel,newtext;
for (i=0;i<x.length;i++){
newel=xmlDoc.createElementNS("p","edition");
newtext=xmlDoc.createTextNode("First");
newel.appendChild(newtext);
x[i].appendChild(newel);}
//Output all titles and editions
y=xmlDoc.getElementsByTagName("title");
z=xmlDoc.getElementsByTagNameNS("p","edition");
for (i=0;i<y.length;i++){
document.write(y[i].childNodes[0].nodeValue);
document.write(" – ");
document.write(z[i].childNodes[0].nodeValue);
document.write(" edition.");
document.write(" Namespace: ");
document.write(z[i].namespaceURI);
document.write("<br />");}
</script></body>
</html>
Output->
Everyday Italian – First edition. Namespace: p
Harry Potter – First edition. Namespace: p
XQuery Kick Start – First edition. Namespace: p
Learning XML – First edition. Namespace: p
0 תשובות