2014-11-04 5 views
0

XElemenet에서 XML 트리의 빈 xmlns="" 속성을 얻습니다. 이런 내가 문서 네임 스페이스에 네임 스페이스를 설정 는 :네임 스페이스를 XElement로 설정합니다.

string xmlns="FreeForm/SchemaDescription"; 
XNamespace ana = xmlns; 
XElement interactiveRootTag = new XElement(ana + "InteractiveRootTag"); 

xmlns=""은 더 이상 존재하지 않고,이 XElement를의 모든 아이는, 빈 xmlns=""를 얻을.

아이디어가 있으십니까?

답변

1

는이 방법으로 자식 요소를 추가 할 수 있습니다

string xmlns="FreeForm/SchemaDescription"; 

XNamespace ana = xmlns; 

XElement interactiveRootTag = new XElement(ana + "InteractiveRootTag"); 
interactiveRootTag.Add(new XElement(ana + "ChildElement", 
    new XAttribute("attribute","AttributeValue"))); 

<InteractiveRootTag xmlns="FreeForm/SchemaDescription"> 
    <ChildElement attribute="AttributeValue" /> 
</InteractiveRootTag> 
같은 XML을 얻으려면
관련 문제