DocumentImpl xmlDoc=new DocumentImpl();
ProcessingInstructionImpl newPI;
Element rootElement = xmlDoc.createElement("commoditys");
newPI=(ProcessingInstructionImpl) xmlDoc.createProcessingInstruction("xml-stylesheet", "type='text/xsl'  href='comm.xsl'");
    xmlDoc.appendChild(newPI);
    xmlDoc.appendChild(rootElement);
Enumeration enmu=hs.elements();
while(enmu.hasMoreElements())
{
comm  s=(comm) enmu.nextElement();
Element tool=xmlDoc.createElement("tool");
    Element name=xmlDoc.createElement("name");
    Element price=xmlDoc.createElement("price");
    Element number=xmlDoc.createElement("number");
    name.appendChild(xmlDoc.createTextNode(s.name));
    price.appendChild(xmlDoc.createTextNode(s.price));
    number.appendChild(xmlDoc.createTextNode(s.number));
    tool.appendChild(name);
    tool.appendChild(price);
    tool.appendChild(number);
    rootElement.appendChild(tool);
}
为什么用 xmlDoc.createProcessingInstruction创建的处理命令,退过xmlDoc.appendChile();加入不到XML问修中啊,哪个大虾这个例子的发下看下,能给小弟解释下更好