将属性添加到节点 [英] Adding attributes to a node
问题描述
我试图将以下属性(xmlns:xsi和xsi:type)添加到节点
(Grantee),如下所示:
< Grantee xmlns:xsi =" http://www.w3.org/2001/XMLSchema-instance"
xsi:type =" Group">
< URI> http://acs.amazonaws.com/groups/s3/LogDelivery< / URI>
< / Grantee>
但是我不清楚如何添加这些类型的属性。以下
似乎无法正常工作。
Scott
XmlNode属性;
attribute = doc.CreateNode(XmlNodeType.Attribute," xsi:type","");
attribute.Value =" Group";
grantee.Attributes.SetNamedItem(attribute);
attribute = doc.CreateNode(XmlNodeType.Attribute," xmlns:xsi","");
attribute.Value =" http://www.w3.org/2001/XMLSchema-instance" ;;
grantee.Attributes.SetNamedItem(attribute);
Ia??m trying to add the following attributes (xmlns:xsi and xsi:type) to a node
(Grantee) like the following:
<Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:type="Group">
<URI>http://acs.amazonaws.com/groups/s3/LogDelivery</URI>
</Grantee>
However I am unclear on how to add these types of attributes. The following
doesn''t seem to work.
Scott
XmlNode attribute;
attribute = doc.CreateNode(XmlNodeType.Attribute, "xsi:type", "");
attribute.Value = "Group";
grantee.Attributes.SetNamedItem(attribute);
attribute = doc.CreateNode(XmlNodeType.Attribute, "xmlns:xsi", "");
attribute.Value = "http://www.w3.org/2001/XMLSchema-instance";
grantee.Attributes.SetNamedItem(attribute);
推荐答案
M1iS写道:
M1iS wrote:
我试图添加以下属性(xmlns:xsi和xsi :type)到一个节点
(受赠人)如下:
< Grantee xmlns:xsi =" http://www.w3。 org / 2001 / XMLSchema-instance"
xsi:type =" Group">
< URI> http://acs.amazon aws.com/groups/s3/LogDelivery</URI>
< / Grantee>
但是我不知道如何添加这些类型的属性。以下
似乎无法正常工作。
Scott
XmlNode属性;
attribute = doc.CreateNode(XmlNodeType.Attribute," xsi:type","");
attribute.Value =" Group";
grantee.Attributes.SetNamedItem(attribute);
attribute = doc.CreateNode(XmlNodeType.Attribute," xmlns:xsi","");
attribute.Value =" http://www.w3.org/2001/XMLSchema-instance" ;;
grantee.Attributes.SetNamedItem(attribute);
Ia??m trying to add the following attributes (xmlns:xsi and xsi:type) to a node
(Grantee) like the following:
<Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:type="Group">
<URI>http://acs.amazonaws.com/groups/s3/LogDelivery</URI>
</Grantee>
However I am unclear on how to add these types of attributes. The following
doesn''t seem to work.
Scott
XmlNode attribute;
attribute = doc.CreateNode(XmlNodeType.Attribute, "xsi:type", "");
attribute.Value = "Group";
grantee.Attributes.SetNamedItem(attribute);
attribute = doc.CreateNode(XmlNodeType.Attribute, "xmlns:xsi", "");
attribute.Value = "http://www.w3.org/2001/XMLSchema-instance";
grantee.Attributes.SetNamedItem(attribute);
而不是做grantee.Attributes.SetNamedItem(属性);
做grantee.Attributes.append(属性);
instead of doing grantee.Attributes.SetNamedItem(attribute);
do grantee.Attributes.append(attribute);
M1iS写道:
M1iS wrote:
我试图添加以下属性(xmlns:xsi和xsi:type)一个节点
(受赠人)如下:
< Grantee xmlns:xsi =" http://www.w3.org/2001/ XMLSchema-instance"
xsi:type =" Group">
< URI> http://acs.amazonaws.com/groups/s3/LogDelivery< / URI>
< / Grantee>
但是我不知道如何添加这些类型的属性。以下
似乎无法正常工作。
Scott
XmlNode属性;
attribute = doc.CreateNode(XmlNodeType.Attribute," xsi:type","");
attribute.Value =" Group";
grantee.Attributes.SetNamedItem(attribute);
attribute = doc.CreateNode(XmlNodeType.Attribute," xmlns:xsi","");
attribute.Value =" http://www.w3.org/2001/XMLSchema-instance" ;;
grantee.Attributes.SetNamedItem(attribute);
Ia??m trying to add the following attributes (xmlns:xsi and xsi:type) to a node
(Grantee) like the following:
<Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:type="Group">
<URI>http://acs.amazonaws.com/groups/s3/LogDelivery</URI>
</Grantee>
However I am unclear on how to add these types of attributes. The following
doesn''t seem to work.
Scott
XmlNode attribute;
attribute = doc.CreateNode(XmlNodeType.Attribute, "xsi:type", "");
attribute.Value = "Group";
grantee.Attributes.SetNamedItem(attribute);
attribute = doc.CreateNode(XmlNodeType.Attribute, "xmlns:xsi", "");
attribute.Value = "http://www.w3.org/2001/XMLSchema-instance";
grantee.Attributes.SetNamedItem(attribute);
对不起doc.CreateNode,它应该是doc.CreateAttribute()
Sorry also instead of doc.CreateNode, it should be doc.CreateAttribute()
好的我试过以下内容:
XmlAttribute属性;
attribute = doc.CreateAttribute(" xmlns:xsi");
attribute.Value =" http://www.w3.org/2001/XMLSchema-instance" ;;
grantee.Attributes.Append(attribute);
attribute = doc.CreateAttribute(" xsi:type");
attribute.Value =" Group";
grantee.Attributes.Append(attribute );
它给了我:
< Grantee xmlns:xsi =" http://www.w3.org/2001/XMLSchema-instance" ;类型= QUOT;组" />
关闭,但不完全在那里。
" Navid"写道:
Okay I tried the following:
XmlAttribute attribute;
attribute = doc.CreateAttribute("xmlns:xsi");
attribute.Value = "http://www.w3.org/2001/XMLSchema-instance";
grantee.Attributes.Append(attribute);
attribute = doc.CreateAttribute("xsi:type");
attribute.Value = "Group";
grantee.Attributes.Append(attribute);
It gives me:
<Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" type="Group" />
Close, but not quite there.
"Navid" wrote:
M1iS写道:
M1iS wrote:
我试图添加以下属性(xmlns: xsi和xsi:type)到一个节点
(受赠人)如下:
< Grantee xmlns:xsi =" http:// www .w3.org / 2001 / XMLSchema-instance"
xsi:type =" Group">
< URI> http://acs.amazonaws.com / groups / s3 / LogDelivery< / URI>
< / Grantee>
但是我不知道如何添加这些类型的属性。以下
似乎无法正常工作。
Scott
XmlNode属性;
attribute = doc.CreateNode(XmlNodeType.Attribute," xsi:type","");
attribute.Value =" Group";
grantee.Attributes.SetNamedItem(attribute);
attribute = doc.CreateNode(XmlNodeType.Attribute," xmlns:xsi","");
attribute.Value =" http://www.w3.org/2001/XMLSchema-instance" ;;
grantee.Attributes.SetNamedItem(attribute);
Ia??m trying to add the following attributes (xmlns:xsi and xsi:type) to a node
(Grantee) like the following:
<Grantee xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:type="Group">
<URI>http://acs.amazonaws.com/groups/s3/LogDelivery</URI>
</Grantee>
However I am unclear on how to add these types of attributes. The following
doesn''t seem to work.
Scott
XmlNode attribute;
attribute = doc.CreateNode(XmlNodeType.Attribute, "xsi:type", "");
attribute.Value = "Group";
grantee.Attributes.SetNamedItem(attribute);
attribute = doc.CreateNode(XmlNodeType.Attribute, "xmlns:xsi", "");
attribute.Value = "http://www.w3.org/2001/XMLSchema-instance";
grantee.Attributes.SetNamedItem(attribute);
对不起doc.CreateNode,它应该是doc.CreateAttribute()
Sorry also instead of doc.CreateNode, it should be doc.CreateAttribute()
这篇关于将属性添加到节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!