我定义了一个函数public static XmlAttribute InsertAttribute(XmlNode oTargetNode, string sAttributeName, string sAttributeValue)
{
XmlNode attr = oTargetNode.OwnerDocument.CreateNode(XmlNodeType.Attribute, sAttributeName,"");
attr.Value = sAttributeValue;
oTargetNode.Attributes.SetNamedItem(attr);
return (System.Xml.XmlAttribute)attr;
}现在当sAttributeName带有 ":" 号的时候,他将解析为 Prefix 和 LocalName 两部分,这时候插入的那个属性就是 LocalName部分了,比如:
XmlElement elem = oParentNode.OwnerDocument.CreateElement("image",sXMLNamespace);
InsertAttribute(elem,"xlink:href",sSrc); //这里我就是要插入"xlink:href",可是得到的是href
InsertAttribute(elem,"x",fX.ToString(sDecimalFormat));
InsertAttribute(elem,"y",fY.ToString(sDecimalFormat));
InsertAttribute(elem,"width",fWidth.ToString(sDecimalFormat));
InsertAttribute(elem,"height",fHeight.ToString(sDecimalFormat));我该怎么办?
下面是我得到的东西:
<image x="685" y="371" width="25" height="34" href="../images/egend.jpg" id="PieColor" />
~~~~~
这里应该是xlink:href,可是被解析成href了
{
XmlNode attr = oTargetNode.OwnerDocument.CreateNode(XmlNodeType.Attribute, sAttributeName,"");
attr.Value = sAttributeValue;
oTargetNode.Attributes.SetNamedItem(attr);
return (System.Xml.XmlAttribute)attr;
}现在当sAttributeName带有 ":" 号的时候,他将解析为 Prefix 和 LocalName 两部分,这时候插入的那个属性就是 LocalName部分了,比如:
XmlElement elem = oParentNode.OwnerDocument.CreateElement("image",sXMLNamespace);
InsertAttribute(elem,"xlink:href",sSrc); //这里我就是要插入"xlink:href",可是得到的是href
InsertAttribute(elem,"x",fX.ToString(sDecimalFormat));
InsertAttribute(elem,"y",fY.ToString(sDecimalFormat));
InsertAttribute(elem,"width",fWidth.ToString(sDecimalFormat));
InsertAttribute(elem,"height",fHeight.ToString(sDecimalFormat));我该怎么办?
下面是我得到的东西:
<image x="685" y="371" width="25" height="34" href="../images/egend.jpg" id="PieColor" />
~~~~~
这里应该是xlink:href,可是被解析成href了
解决方案 »
- 首页静化大家都是怎么做的?
- 大侠帮我找一下错(datareader相关)~~
- 关于FORM验证后,浏览器中的地址http://localhost:10097/Login.aspx?ReturnUrl=%2fShowDetail.aspx,为什么会这样?
- 全局共享一个SqlConnect的问题
- 我在C#后台页面中定义的int型变量赋值后,随后访问其值怎么都变为0x开头的数字?
- 问个菜鸟问题!关于DataReader
- 毕业论文选题系统的“自动定选”模块的设计实现
- 新手请教div样式问题!!
- 如何快速定位到datagrid的某一页?
- Windows Service用try捕获exception怎么不行?
- 怎么办?怎么办?
- 为何无法属性设定空字符串?
如果已经定义了,那么这里就再没有必要写xlink:href,因为默认就是xlink:href如果非得在已经定义了xlink的前提下,还得让其输出xlink:href,可以这样:
public static XmlAttribute InsertAttribute(XmlNode oTargetNode, string sAttributeName, string sAttributeValue, string ns)
{
XmlNode attr = oTargetNode.OwnerDocument.CreateAttribute(sAttributeName,ns);
attr.Value = sAttributeValue;
oTargetNode.Attributes.SetNamedItem(attr);
return (System.Xml.XmlAttribute)attr;
}
调用时:
// 比如某一个父结点定义了xmlns:xlink="http://www.xlink.org"
string ns = "http://www.xlink.org";
InsertAttribute(elem,"xlink:href",sSrc,ns);
>>>
还是有必要地,俺也糊涂了 :P
<image x="68" y="109" width="182" height="112" xlink:href="109330923398697.jpg" stroke="#000000" />
</svg>这个文件是正常的,可是当我去掉了xlink就看不到图片了,请问我该怎么定义xlink呢?
用你的方法,它会在后面加 xmlns:xlink="xlink" ,也还是没法看到图片。
孟子应该会这个
http://community.csdn.net/Expert/TopicView3.asp?id=3927237
我也是今天早上才看到的,昨天发的时候还不知道自己多发了,呵呵,你Up一下,我一起揭帖,要不然那个帖子结不了。
虽然分数对你可能没什么,但这也是我现在唯一能表示我感谢的东西了。哈哈。