我正在开发一个代表我生成博客文章的程序。在大多数情况下,这工作正常但我的问题出现在我使用iframe嵌入Youtube视频时。
出于某种原因,我的html被重写了。即关闭iframe标记移动到帖子的末尾,然后是结束div。
最初,我认为我正在错误地连接帖子的各个片段但是当我调试时,一切都按照正确的顺序。
这是我实际插入的内容:
<div>
<span style="font-family: Arial, Helvetica, sans-serif, font-size: large;">
In this video, I am going to show you how to format a post for blogger. You can read the transcript below.
<br/><br/></span>
</div>
<h2>HTML Player</h2>
<div>
<iframe allowfullscreen="" frameborder="0" height="315" src="http://www.youtube.com/embed/68p_LKet2Kw" width="560"></iframe>
</div>
<div>
<h2>Transcript</h2>
Sadly, my html is being re-written for some reason.
<br/><br/>
</div>
<div>
<span style="font-family: Arial, Helvetica, sans-serif, font-size: large;">See you soon.<br/></span>
<br/>
</div>
这就是Blogger中生成的内容:
<div>
<span style="font-family: Arial, Helvetica, sans-serif, font-size: large;">
In this video, I am going to show you how to format a post for blogger. You can read the transcript below.
<br />
</span>
</div>
<h2>HTML Player</h2>
<div>
<iframe allowfullscreen="" frameborder="0" height="315" src="http://www.youtube.com/embed/68p_LKet2Kw" width="560">
</div>
<div>
<h2>Transcript</h2>
Sadly, my html is being re-written for some reason.
<br/><br/>
</div>
<div>
<span style='font-family: Arial, Helvetica, sans-serif, font-size: large;'>
See you soon.
<br/><br/>
</span>
<br/>
</div>
</iframe></div>
注意关闭的iframe标记是如何移动的,以及附加了一个附加的div。
这是我的代码:
service = new Service("blogger", Applicationname);
credentials = new GDataCredentials(Username, Password);
service.Credentials = credentials;
GDataGAuthRequestFactory bRequest = (GDataGAuthRequestFactory)service.RequestFactory;
bRequest.AccountType = "GOOGLE";
AtomEntry newPost = new AtomEntry();
newPost.Title.Text = _Entry.Title;
newPost.Content = new AtomContent();
BlogContent += BlogSectionTopic;
BlogContent += "<h2>HTML Player</h2>";
BlogContent += BlogSectionHtmlEmbed;
BlogContent += "<div>";
BlogContent += "<h2>Transcript</h2>";
BlogContent += _BlogBody;
BlogContent += "<br/>";
BlogContent += "<br/>";
BlogContent += "</div>";
newPost.Content.Content = BlogContent;
newPost.Content.Type = "xhtml";
newPost.Updated = DateTime.Now;
newPost.Published = DateTime.Now;
Uri blogFeedUri = null;
foreach (var category in categories.Split(','))
{
newPost.Categories.Add(new AtomCategory(category,new Uri("http://www.blogger.com/atom/ns#")));
}
newPost.Categories.Add(new AtomCategory("Video", new Uri("http://www.blogger.com/atom/ns#")));
string tmpURI = GetPostingURI(service, "http://www.philipstirpe.co.uk/feeds/posts/default");
if (tmpURI != "")
{
blogFeedUri = new Uri(tmpURI);
createdEntry = service.Insert(blogFeedUri, newPost);
}
非常感谢您的回答和帮助。
答案 0 :(得分:0)
问题解决了。我终于发现我错误地将AtomEntry的内容类型设置为“xhtml”而不是“html”。