以文本方式查看主题 - 计算机科学论坛 (http://bbs.xml.org.cn/index.asp) -- 『 SVG/GML/VRML/X3D/XAML 』 (http://bbs.xml.org.cn/list.asp?boardid=21) ---- SVG DOM访问问题 (http://bbs.xml.org.cn/dispbbs.asp?boardid=21&rootid=&id=15300) |
-- 作者:molester -- 发布时间:3/9/2005 5:44:00 PM -- SVG DOM访问问题 SVG文件如下,很简单的含g元素的文件 <?xml version="1.0" encoding="ISO-8859-1" standalone="no"?> <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd" [ <!ATTLIST svg xmlns:xlink CDATA #FIXED "http://www.w3.org/1999/xlink"> ]> <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <g style="opacity: 0.5"> <rect id="r5" x="50" y="60" width="100" height="50" style="fill: #F00"/> <circle cx="70" cy="120" r="40" style="fill: #00C"/> </g> </svg> .net下访问它,代码如下: XmlDocument doc=new XmlDocument(); Response.Write(doc..InnerXml)可以看到文档里面的内容。但是希望找到某个元素的属性时,就有问题了,比如说加上下面代码 未将对象引用设置到对象的实例。 异常详细信息: System.NullReferenceException: 未将对象引用设置到对象的实例。 源错误: |
-- 作者:rido -- 发布时间:3/11/2005 9:49:00 AM -- 按规范,函数名不会有“GetAttribute()”,应该为“getAttribute()” |
-- 作者:molester -- 发布时间:3/16/2005 2:43:00 PM -- 调用的是.net的xmldocument,不是msxml |
-- 作者:rido -- 发布时间:3/17/2005 8:51:00 AM -- 看错了,以为java呢。 没看过.net,这是C#语法吧? 不过也真是,C#既然要模仿java,规范却另搞一套。 |
-- 作者:molester -- 发布时间:3/22/2005 11:11:00 AM -- 对啊,.net不支持msxml,没办法啊 |
-- 作者:henrybenben -- 发布时间:4/13/2005 10:58:00 PM -- var xmlDoc = SVGEmbed.window.parseXML(templeContent.content).documentElement; var frag = SVGEmbed.window.parseXML(SVGEmbed.window.printNode(xmlDoc.getElementsByTagName("rect").item(0)),SVGDocument); SVGDocument.rootElement.appendChild(frag.firstChild); 试试这样,应该可以的! |
W 3 C h i n a ( since 2003 ) 旗 下 站 点 苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》 |
78.979ms |