0

我正在使用 DOM 创建元素,我的问题是如何创建如下路径

FieldType Abstract="false" Name="New Entity0" m:HasStream="false"

我已经创建了标签,<FieldType>但我不知道如何继续使用Abstract="false"and Name="New field"等。

代码是:

 Element fld = document.createElement("FieldType");

谢谢!!!

4

2 回答 2

1

Next, you would simply do:

fId.setAttribute("Abstract", "false");
fId.setAttribute("Name", "New Entity0");

See the element javadoc for more information.

Make sure you don't forget append the element to the document when you're done!

于 2012-10-16T12:10:40.690 回答
-1

例子

L_div = document.createElement("div");
L_div.id="div_emp_detl";
L_div.className="cls_div_header";
document.body.appendChild(L_div);

对于您的情况

fld.name = "New Entity";
fld.Abstract="false"
于 2012-10-16T12:11:29.880 回答