如何通过C#代码在KML中写入引号
也许这是一个愚蠢的问题,但我的 html 技能现在已经消失了..:)
我正在通过单击按钮创建一个 KML 文件,并且 KML 标签的所有代码都在那里。我需要的是使用多个标签。它将被硬编码在 KML 的开头。 KML 应如下所示:
因此,此代码是从后面的 C# 代码生成的。所以问题是如何
<Style id= "randomColorIcon">
在没有 id 部分的情况下像 /Style 一样获取然后正确关闭标签?
在 C# 代码中,我有类似的内容,但我发现它无法读取其他样式 id 标签,
kml.WriteStartElement("Style");
kml.WriteElementString("id", "randomColorIcon"); //not suitable for more than one Style tags
kml.WriteStartElement("IconStyle");
kml.WriteStartElement("Icon");
kml.WriteElementString("href", "http://maps.google.com/mapfiles/kml/pal3/icon23.png");
kml.WriteEndElement(); //</Icon>
kml.WriteEndElement(); //</IconStyle> ??
kml.WriteEndElement(); //</Style>
提前致谢:)
maybe a stupid question here but my html skills are faded now.. :)
I am creating a KML file with a button click and all the code for the KML tags is there. What I need is using more than one tags. It will be hardcoded in the beginning of the KML. The KML should look something like this:
So this code is generated from the C# code behind. So the question is how to get
<Style id= "randomColorIcon">
and then close the tag properly like /Style without having the id part?
In the C# code I had something like this but I just found that it doesn't read the other Style id tags
kml.WriteStartElement("Style");
kml.WriteElementString("id", "randomColorIcon"); //not suitable for more than one Style tags
kml.WriteStartElement("IconStyle");
kml.WriteStartElement("Icon");
kml.WriteElementString("href", "http://maps.google.com/mapfiles/kml/pal3/icon23.png");
kml.WriteEndElement(); //</Icon>
kml.WriteEndElement(); //</IconStyle> ??
kml.WriteEndElement(); //</Style>
Thanks in advance :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
就 XML 而言:
和:
是等价的。
在这方面,以下内容将产生与您所要求的语义等效的内容:
As far as XML is concerned:
And:
Are equivalent.
In that respect, the following will produce the semantic equivalent of what you are asking for:
您将需要 WriteAttributeString。
You'll need WriteAttributeString.