views:

35

answers:

3

I'm looking for any resources concerning an ASPX file parser and object model.

I'm trying to read, modify an write ASPX and ASCX files. I tried SGMLReader/XmlDocument, but this does not accept the "<% ... %>" statements.

+1  A: 

I can't for the life of me fathom why you'd be trying to do this, but you might want to look at the HTML Agility Pack:

"This is an agile HTML parser that builds a read/write DOM and supports plain XPATH or XSLT (you actually don't HAVE to understand XPATH nor XSLT to use it, don't worry...). It is a .NET code library that allows you to parse "out of the web" HTML files. The parser is very tolerant with "real world" malformed HTML. The object model is very similar to what proposes System.Xml, but for HTML documents (or streams)."

Dan Diplo
I know, this is nothing common. It's for kind of importing/exporting purpose.
Michael Stoll
Just checked it. It's a nice library. Though it's not suitable for parsing aspx. Maybe with some modifications.
Michael Stoll
A: 

Don't do it! You have too much to live for!

zincorp
I won't implement that all by myself, but maybe there are some libraries, which fit to the purpose.
Michael Stoll
+1  A: 

The DMS Software Reengineering Toolkit can parse C#, both as full files and in fragments (e.g., the stuff inside the <% %> brackets) and can parse HTML both in clean and dirty format (the stuff you really see in HTML files). DMS automatically produces trees ("DOM models") for what it parses.

With minor bit of effort, and HTML dialect with <% %> would be easy to define, and then one could parse ASPX files. We've done essentially this for PHP already.

Ira Baxter
I think this would be a good solution. But currently it's to expensive.
Michael Stoll