悬赏园豆:30
[已关闭问题]
<P>这几天正在看google到sitemaps的xml.</P>
<P>现在我发现个问题。</P>
<P><urlset xmlns="<A href="http://www.google.com/">http://www.google.com/</A>"><BR> <url></url><BR></urlset></P>
<P>为什么我生成的就成了</P>
<P><urlset xmlns="<A href="http://www.google.com/">http://www.google.com/</A>"><BR> <url xmlns="" ></url><BR></urlset></P>
<P>源码</P>
<DIV class=cnblogs_code><IMG id=Code_Closed_Image_183533 onclick="this.style.display='none'; Code_Closed_Text_183533.style.display='none'; Code_Open_Image_183533.style.display='inline'; Code_Open_Text_183533.style.display='inline';" height=16 src="http://space.cnblogs.com/Images/OutliningIndicators/ContractedBlock.gif" width=11 align=top><IMG id=Code_Open_Image_183533 style="DISPLAY: none" onclick="this.style.display='none'; Code_Open_Text_183533.style.display='none'; Code_Closed_Image_183533.style.display='inline'; Code_Closed_Text_183533.style.display='inline';" height=16 src="http://space.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif" width=11 align=top><SPAN id=Code_Closed_Text_183533 style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">Code</SPAN><SPAN id=Code_Open_Text_183533 style="DISPLAY: none"><BR><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><SPAN style="COLOR: #008080"> 1</SPAN><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000"> System.Xml.XmlDocument doc1 </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000"> XmlDocument();<BR></SPAN><SPAN style="COLOR: #008080"> 2</SPAN><SPAN style="COLOR: #000000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top> System.Xml.XmlDeclaration declaration1</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> doc1.CreateXmlDeclaration(</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN style="COLOR: #800000">1.0</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN style="COLOR: #800000">utf-8</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #0000ff">null</SPAN><SPAN style="COLOR: #000000">);<BR></SPAN><SPAN style="COLOR: #008080"> 3</SPAN><SPAN style="COLOR: #000000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top> doc1.AppendChild(declaration1);<BR></SPAN><SPAN style="COLOR: #008080"> 4</SPAN><SPAN style="COLOR: #000000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top> XmlElement docroot </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> doc1.CreateElement(</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN style="COLOR: #800000">urlset</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN style="COLOR: #000000">);<BR></SPAN><SPAN style="COLOR: #008080"> 5</SPAN><SPAN style="COLOR: #000000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top> <BR></SPAN><SPAN style="COLOR: #008080"> 6</SPAN><SPAN style="COLOR: #000000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top> System.Xml.XmlAttribute rootattr </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> doc1.CreateAttribute(</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN style="COLOR: #800000">xmlns</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN style="COLOR: #000000">,</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN style="COLOR: #800000">http://www.w3.org/2000/xmlns/</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN style="COLOR: #000000">);<BR></SPAN><SPAN style="COLOR: #008080"> 7</SPAN><SPAN style="COLOR: #000000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top> rootattr.Value </SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000"> </SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN style="COLOR: #800000">http://www.google.com/schemas/sitemap/0.84</SPAN><SPAN style="COLOR: #800000">"</SPAN><SPAN style="COLOR: #000000">;<BR></SPAN><SPAN style="COLOR: #008080"> 8</SPAN><SPAN style="COLOR: #000000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top> docroot.Attributes.Append(rootattr);<BR></SPAN><SPAN style="COLOR: #008080"> 9</SPAN><SPAN style="COLOR: #000000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top> XmlNode urlnode = doc1.CreateNode(XmlNodeType.Element,"url",null);</SPAN></SPAN></DIV>
<DIV class=cnblogs_code><SPAN style="DISPLAY: none"><SPAN style="COLOR: #000000"> docroot.AppendChild(urlnode);<BR></SPAN><SPAN style="COLOR: #008080">10</SPAN><SPAN style="COLOR: #000000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top> doc1.AppendChild(docroot);<BR></SPAN><SPAN style="COLOR: #008080">11</SPAN><SPAN style="COLOR: #000000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top> doc1.Save(m_path);<BR></SPAN><SPAN style="COLOR: #008080">12</SPAN><SPAN style="COLOR: #000000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top></SPAN></SPAN></DIV>