简体   繁体   English

将HTML ID添加到.aspx文件中的标签

[英]Add HTML Id's to tags in .aspx file

So I'm writing an app that lets the user select a folder, it gets all the .aspx files in that folder, and lets the users check off which ones they want to add HTML ID's to. 所以我正在编写一个应用程序,让用户选择一个文件夹,它获取该文件夹中的所有.aspx文件,并让用户检查他们想要添加HTML ID的文件。

Then they click start, and this runs 然后他们点击开始,然后运行

private void btnStart_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < listFiles.CheckedItems.Count; i++)
            {

            }
        }

It loops through all the selected file names. 它遍历所有选定的文件名。 How do I open each of these .aspx files in the background, and go through them and add the 我如何在后台打开每个这些.aspx文件,并遍历它们并添加

id="thisItemId"

attribute to each tag that's like a , , , , , etc.... 属性为每个标记,如a ,,,,等....

Assuming you know how to do basic file IO, I recommend using the HTML Agility Pack to parse the ASPX files. 假设您知道如何执行基本文件IO,建议您使用HTML Agility Pack来解析ASPX文件。 Using that library you can modify the HTML elements in which you're interested, and then save the file back using some more basic file IO. 使用该库,您可以修改感兴趣的HTML元素,然后使用一些更基本的文件IO将文件保存回去。

LinqToHTML将完成这项工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM