这个字符串格式有什么问题吗?
我想知道是否有人知道这个 html 字符串代码是怎么回事:
<object height=\\\"38\" + \"5\\\" width=\\\"64\" + \"0\\\" classid=\\\"clsid:D27CDB6E-
AE6D-11cf-96B8-444553540000\\\" id=\\\"movie_player\\\" ><param name=\\\"movie\\\"
value=\\\"http:\\/\\/s.ytimg.com\\/yt\\/swf\\/watch_as3-vfl186120.swf\\\"><param
name=\\\"flashvars\\\" value=\\\"...." allowscriptaccess=\\\"always\\\"
allowfullscreen=\\\"true\\\" bgcolor=\\\"#000000\\\" \\/>
它看起来很可怕......它嵌入在 JavaScript 函数中,稍后将呈现到页面上。谁能告诉我如何使用 Html Agility Pack 或可能的 RegEx 来清理它,尽管它看起来很乱!
重要的方面是让 height=\\\"38\" + \"5\\\"
变为 height="385"
等。我可以摆脱过度削减没有问题。
非常感谢任何指导。
编辑:最后,这就是我用来完成标签的内容,
objectNodeFormat.Replace(@"\", "");
objectNodeFormat.Replace(@" + ", "");
objectNodeFormat.Replace(@"""""", "");
再次感谢。
I was wondering if anyone knows what's up with this html string code:
<object height=\\\"38\" + \"5\\\" width=\\\"64\" + \"0\\\" classid=\\\"clsid:D27CDB6E-
AE6D-11cf-96B8-444553540000\\\" id=\\\"movie_player\\\" ><param name=\\\"movie\\\"
value=\\\"http:\\/\\/s.ytimg.com\\/yt\\/swf\\/watch_as3-vfl186120.swf\\\"><param
name=\\\"flashvars\\\" value=\\\"...." allowscriptaccess=\\\"always\\\"
allowfullscreen=\\\"true\\\" bgcolor=\\\"#000000\\\" \\/>
It looks horrible... It is embedded in a JavaScript function, to later be rendered to the page. Can anyone tell me how I can clean it using say Html Agility Pack or possibly RegEx although it looks messy!
Important aspect is getting the height=\\\"38\" + \"5\\\"
to become height="385"
etc. I can get rid of the excesses slashes no problem.
Really appreciate any guidance.
Edit: in the end this is what I used to complete the tags
objectNodeFormat.Replace(@"\", "");
objectNodeFormat.Replace(@" + ", "");
objectNodeFormat.Replace(@"""""", "");
Thanks again.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来双反斜杠是为了转义斜杠,第三个反斜杠是为了转义引号......哇!它看起来确实很乱......比如说......将所有字符串填充到 StringBuilder 中并使用 StringBuilder 对象的
RemoveReplace 方法来删除所有这些反斜杠......编辑:将其更改为替换 - mea culpa
Looks like the double backslash is to escape the slash and the third backslash to escape the quote... wow! it does look messy.... say... stuff all that string into a StringBuilder and use the
RemoveReplace method of the StringBuilder object to strip out all those backslashes...Edit: Changed it to Replace - mea culpa