C# 使用C“如何设置移动站点地图XML”;urlset";(谷歌推荐)

C# 使用C“如何设置移动站点地图XML”;urlset";(谷歌推荐),c#,xml,sitemap,C#,Xml,Sitemap,我正在尝试将谷歌推荐的移动站点地图标题添加到我的页面中,即: <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0"> 它生成以下xml: <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> 然后我得到以下

我正在尝试将谷歌推荐的移动站点地图标题添加到我的页面中,即:

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
  xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0">
它生成以下xml:

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
然后我得到以下结果:

<mobile:urlset mobile:xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
sitemap.WriteStartElement("urlset", "http://www.sitemaps.org/schemas/sitemap/0.9");
sitemap.WriteAttributeString("xmlns", "mobile", string.Empty, "http://www.google.com/schemas/sitemap-mobile/1.0");

我怎样才能做到这一点

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
  xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0">

查看API,
sitemap
对象似乎是
XmlWriter
。要编写自定义命名空间,请使用以下命令:

<mobile:urlset mobile:xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
sitemap.WriteStartElement("urlset", "http://www.sitemaps.org/schemas/sitemap/0.9");
sitemap.WriteAttributeString("xmlns", "mobile", string.Empty, "http://www.google.com/schemas/sitemap-mobile/1.0");

查看API,
sitemap
对象似乎是
XmlWriter
。要编写自定义命名空间,请使用以下命令:

<mobile:urlset mobile:xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
sitemap.WriteStartElement("urlset", "http://www.sitemaps.org/schemas/sitemap/0.9");
sitemap.WriteAttributeString("xmlns", "mobile", string.Empty, "http://www.google.com/schemas/sitemap-mobile/1.0");

谢谢@Candide。。。在你的帮助下,我能够解决问题,但不得不稍微调整一下。我就是这样让它工作的:

sitemap.WriteStartElement("urlset");
sitemap.WriteAttributeString("xmlns", "http://www.google.com/schemas/sitemap-mobile/1.0");
sitemap.WriteAttributeString("xmlns:mobile", "http://www.google.com/schemas/sitemap-mobile/1.0");
这在xml上输出为:

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0">

谢谢@Candide。。。在你的帮助下,我能够解决问题,但不得不稍微调整一下。我就是这样让它工作的:

sitemap.WriteStartElement("urlset");
sitemap.WriteAttributeString("xmlns", "http://www.google.com/schemas/sitemap-mobile/1.0");
sitemap.WriteAttributeString("xmlns:mobile", "http://www.google.com/schemas/sitemap-mobile/1.0");
这在xml上输出为:

<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0">


sitemap对象的类型是什么?sitemap对象的类型是什么?