2017-12-29 7 views
0

XMI 구조를 다시 작성하려고합니다. 그래서 그것을 위해 내가 Xelement의 setattribute 속성에서 속성 이름이 중복됩니다.

<node xmi:type="shape" xmi:id="12358" type="rectangle"> 
</node > 

은 그래서 들은 XMLElement을 만들고 난을 얻을 수 있도록 네임 스페이스 URL을 사용하여 코드

XmlElement child= papNotdoc.CreateElement("node"); 
child.SetAttribute("type", "http://www.omg.org/XMI", "Shape"); 
child.SetAttribute("id", "http://www.omg.org/XMI","12358"); 
child.SetAttribute("type", "rectangle"); 

이하로 사용하여 속성을 추가하려고 아래처럼 자식 노드를 추가 할 필요가 접두어 속성 중 하나에 XMI :이 있습니다.

그러나 불행하게도 XML 요소는 동일한 속성으로 두 종류라는 이름의 속성을 취급하고 나에게 다음과 같은 출력을 제공

<node xmi:type="rectangle" xmi:id="12358"> 
</node > 

내가 원하는 모두 XMI하십시오 node.How 입력유형 특성에 를 성취하다 ?

답변

1

nullSetAttribute 메서드의 namespaceURI 매개 변수에 지정해야합니다.

XmlElement child = papNotdoc.CreateElement("node"); 
child.SetAttribute("type", "http://www.omg.org/XMI", "Shape"); 
child.SetAttribute("id", "http://www.omg.org/XMI", "12358"); 
child.SetAttribute("type", null, "rectangle"); 
+0

정말인가요? 왜냐하면 기본 접두어 이름을 가진 또 하나를 추가했기 때문입니다. – lucky

+0

@Rainman - 작동하는 것처럼 보이지만 https://dotnetfiddle.net/VDnQaw를 참조하십시오. – dbc

관련 문제