about XML&DOM:一个简单问题和一个奇怪问题

JoySwing 2001-08-21 11:26:26
1.怎么检验schema的正确性
2.使用DOM中发生的问题
我需要在parentnode下创建一个节点:
<Folder FolderName="Math" UID="s8"></Folder>

'以下是代码
Set parentnode = XMLDoc.nodeFromID(xmlUID) '得到某一节点
Set testnode = XMLDoc.createElement("Folder") '
testnode.setAttribute "FolderName", "Math"
testnode.setAttribute "UID", NewID
parentnode.appendChild testnode

XMLDoc.save docPath
DisplayTree

结果创建出来的节点总是这样:
<Folder xmlns="" FolderName="Math" UID="s8"></Folder>
总是多出来 xmlns="" 这个属性 怎么回事啊?

btw:我的xml文档用schema定义过
一定给分!多谢!
...全文
101 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
JoySwing 2001-08-22
  • 打赏
  • 举报
回复
谢谢Zee,请大家继续关注第二问题 非常头痛!
JoySwing 2001-08-22
  • 打赏
  • 举报
回复
原来如此 !
试了一下成功了
thank you !
karma 2001-08-22
  • 打赏
  • 举报
回复
replace
Set testnode = XMLDoc.createElement("Folder")
with
set testnode = XMLDoc.createNode(1,"Folder","x-schema:schema2.xdr")
JoySwing 2001-08-22
  • 打赏
  • 举报
回复
up
karma 2001-08-22
  • 打赏
  • 举报
回复
did you define a namespace in your original XML file? show us the file
JoySwing 2001-08-22
  • 打赏
  • 举报
回复
我定义了Schema,不知道这算不算namespace的特例
<!-- schema2.xdr -->
<?xml version="1.0" encoding="GB2312"?>
<Schema xmlns="urn:schemas-microsoft-com:xml-data" xmlns:dt="urn:schemas-microsoft-com:datatypes">

<!-- Attribute list -->
<AttributeType name="FolderName" dt:type="string" />
<AttributeType name="LastUID" dt:type="string" />
<AttributeType name="UID" dt:type="id" />

<AttributeType name="TopicTitle" dt:type="string"/>
<AttributeType name="TopicURL" dt:type="string" />
<AttributeType name="TopicComment" dt:type="string" />

<!-- Element list -->

<ElementType name="Topic" content="textOnly" >
<attribute type="UID"/>
<attribute type="TopicTitle"/>
<attribute type="TopicURL"/>
<attribute type="TopicComment"/>
</ElementType>


<ElementType name="Folder" content="eltOnly">
<attribute type="UID"/>
<attribute type="FolderName"/>

<group maxOccurs="*" minOccurs="0" order="many" >
<element type="Folder"/>
</group>
<group maxOccurs="*" minOccurs="0" order="many" >
<element type="Topic"/>
</group>

</ElementType>

<ElementType name="RootFolder" content="eltOnly">
<attribute type="UID"/>
<attribute type="FolderName"/>
<attribute type="LastUID"/>

<group maxOccurs="*" minOccurs="0" order="many" >
<element type="Folder"/>
</group>
<group maxOccurs="*" minOccurs="0" order="many" >
<element type="Topic"/>
</group>

</ElementType>

</Schema>


<!-- test.xml -->

<?xml version="1.0" encoding="GB2312"?>
<RootFolder FolderName="文档" xmlns="x-schema:schema2.xdr" UID="d1" LastUID="d6">
<Folder FolderName="Reading" UID="d4">
<Topic TopicTitle="是当今电动机可" TopicURL="http:\\www.sina.com.cn" TopicComment="简单" xml:space="preserve" UID="d5">
文本文本文本文本
</Topic>
</Folder>
<Folder FolderName="Program" UID="d2">
<Topic TopicTitle="关闭windows" TopicURL="http:\\www.sina.com.cn" TopicComment="简单" xml:space="preserve" UID="d3">
文本文本文本
</Topic>
<Folder FolderName="Test" UID="d6">
/Folder>
</Folder>
</RootFolder>
上面的xml用dom写的,比较乱,凑活看吧

Zee 2001-08-21
  • 打赏
  • 举报
回复
About 1
在DOM Load前设置validateOnParse 属性=True

8,906

社区成员

发帖
与我相关
我的任务
社区描述
XML/XSL相关问题讨论专区
社区管理员
  • XML/XSL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧