3
我想更多的要求添加到ClaimTypesOffered元素,如下图所示:生成XML命名空间
<fed:ClaimTypesOffered>
<auth:ClaimType Uri="http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name" Optional="true" xmlns:auth="http://docs.oasis-open.org/wsfed/authorization/200706">
<auth:DisplayName>Name</auth:DisplayName>
<auth:Description>The name of the subject.</auth:Description>
</auth:ClaimType>
</fed:ClaimTypesOffered>
有很多的命名空间魔术那儿的情况,我想通过它的工作我的方式。只是获得正确的元素名称是困难的。我已经尝试了所有的以下内容:
new XElement(XNamespace.Get("auth") + "ClaimType", "somedata");
给
<ClaimType xmlns="auth">somedata</ClaimType>
和
new XElement(XName.Get("{http://docs.oasis-open.org/wsfed/authorization/200706}auth"), "somedata");
给
<auth xmlns="http://docs.oasis-open.org/wsfed/authorization/200706">somedata</auth>
和
new XElement("auth:ClaimType", "somedata");
给
System.Xml.XmlException : The ':' character, hexadecimal value 0x3A, cannot be included in a name.
我寻求帮助,相处这进一步,生成包括属性和内在要素的要求的完整的例子将是真棒,即使是很小的推在正确的方向将不胜感激。
尝试在[所以]为['[XML名称空间] [LINQ到XML]'](http://stackoverflow.com/questions/tagged/xml-namespaces+linq-to搜索-xml) –
http://stackoverflow.com/questions/6747304/in-c-is-there-a-way-to-generate-an-xdocument-using-the-short-prefix-instead-of –
@JohnSaunders发布这意味着有类似于我的问题的现有答案。我搜索了现有的答案,发现与名称空间生成XML很少有关系。对我来说,这个回应基本上等于“google it”。 – jjr2527