首页 新闻 会员 周边 捐助

xml中xmlns的问题

0
悬赏园豆:30 [已关闭问题]
<P>这几天正在看google到sitemaps的xml.</P> <P>现在我发现个问题。</P> <P>&lt;urlset xmlns="<A href="http://www.google.com/">http://www.google.com/</A>"&gt;<BR>&nbsp;&lt;url&gt;&lt;/url&gt;<BR>&lt;/urlset&gt;</P> <P>为什么我生成的就成了</P> <P>&lt;urlset xmlns="<A href="http://www.google.com/">http://www.google.com/</A>"&gt;<BR>&nbsp;&lt;url xmlns="" &gt;&lt;/url&gt;<BR>&lt;/urlset&gt;</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">&nbsp;1</SPAN><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;System.Xml.XmlDocument&nbsp;doc1&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</SPAN><SPAN style="COLOR: #0000ff">new</SPAN><SPAN style="COLOR: #000000">&nbsp;XmlDocument();<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;2</SPAN><SPAN style="COLOR: #000000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;System.Xml.XmlDeclaration&nbsp;declaration1</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;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">&nbsp;3</SPAN><SPAN style="COLOR: #000000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;doc1.AppendChild(declaration1);<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;4</SPAN><SPAN style="COLOR: #000000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;XmlElement&nbsp;docroot&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;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">&nbsp;5</SPAN><SPAN style="COLOR: #000000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;6</SPAN><SPAN style="COLOR: #000000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;System.Xml.XmlAttribute&nbsp;rootattr&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;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">&nbsp;7</SPAN><SPAN style="COLOR: #000000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;rootattr.Value&nbsp;</SPAN><SPAN style="COLOR: #000000">=</SPAN><SPAN style="COLOR: #000000">&nbsp;</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">&nbsp;8</SPAN><SPAN style="COLOR: #000000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;docroot.Attributes.Append(rootattr);<BR></SPAN><SPAN style="COLOR: #008080">&nbsp;9</SPAN><SPAN style="COLOR: #000000"><IMG src="http://space.cnblogs.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp; XmlNode urlnode = doc1.CreateNode(XmlNodeType.Element,"url",null);</SPAN></SPAN></DIV> <DIV class=cnblogs_code><SPAN style="DISPLAY: none"><SPAN style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 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>&nbsp;&nbsp;&nbsp;&nbsp;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>&nbsp;&nbsp;&nbsp;&nbsp;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>
shengnet的主页 shengnet | 初学一级 | 园豆:31
提问于:2008-07-16 18:35
< >
分享
其他回答(3)
0
代码不全,看不到问题
丁学 | 园豆:18730 (专家六级) | 2008-07-17 07:47
0
第9行改用doc1.CreateElement('url');试试。
玉开 | 园豆:8822 (大侠五级) | 2008-07-17 08:41
0
Jared.Nie | 园豆:1940 (小虾三级) | 2008-07-27 08:23
0

怎么解决的?

miles.chen | 园豆:202 (菜鸟二级) | 2012-04-27 10:15
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册