visual studio 2008 extended c# intellisense
If I have an xml file like this:
<?xml version="1.0" ?>
<CATALOG>
<TITLE>Title1</TITLE>
<COUNTRY>USA</COUNTRY>
</CATALOG>
can I call Catalog tag like a class name from intellisense when I edit c# applicat开发者_JAVA百科ion ? and his child Title1 and USA ?
Example with intellisense VS 2008 c# :
1) System.DateTime.Now;
2) and in my case: Catalog Catalog.Title1 Catalog.USA
and the MOST important thing is: I don't need to have any assembly references or no implemented classes. I must to solve this task only with xml files without dlls or classes. It's possible? and how?
Thanks!
you can do something as follows
XDocument catalogueXml
= XDocument.Load("books.xml");
CatalogItem item = (from catalog in
catalogueXml.Descendants("CATALOG")
select new CatalogItem
{
Name = catalog.Element("TITLE").Value,
Country = catalog.Element("COUNTRY").Value
}).FirstOrDefault();
you can still get anonymous object but better to have a defined class
public class CatalogItem
{
public string Name { get; set; }
public string Country { get; set; }
}
for step by step process and better insight, this is a must have read
- Clever: XML to Schema Inference Wizard for Visual Studio 2008
It's not possible without coding it yourself in a wrapper class. The closest you'll get it linq to xml, but of course, thats an assembly you'd need to register!
精彩评论