2012-01-03 2 views
1

という名前でXElementという名前のオブジェクトを作成しましたが、 ':'を名前に含めることはできません。XElementでXMLパーズ ':'

ここで、最初のストリームは名前空間です。

+3

コードを投稿することで、既に試したことを示すことをお勧めします。おそらくネームスペースを含むXNameを作成する必要があります。 (文字列は暗黙的にXNamesに変換されます) –

+0

こんにちは。 xmppチャットクライアントの作成方法については疑問を持っています。これは私のポストです。http://stackoverflow.com/questions/9781975/xmpp-chat-c​​lient-in-windows-phone-7-5 xmppチャットアプリの最初の段階を越えたので、あなたの答えは大きな助けになるでしょう私。 –

答えて

5

あなたは、このように名前空間を指定します。

XNamespace streamNs = "some-url-here"; 
// The + operator here creates an XName 
XElement element = new XElement(streamNs + "stream"); 

は、これが作成するようにするには"stream:stream"の要素の場合、streamの属性はxmlnsとする必要があります。

// Add this to an element - either the element in the namespace, or some parent 
// element. The document root is a common place to put all namespaces... 
XAttribute streamNs = new XAttribute(XNamespace.Xmlns + "stream", 
            streamNs.NamespaceName); 
関連する問題