我的web.sitemap是
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode url="~/Index.aspx?id=Home" title="Dashboard" description="">
<!-- Catalog Management-->
<siteMapNode url="~/Index.aspx?id=CategoryHome&category=CatalogManagement" title="Catalog Management" description="">
<siteMapNode url="~/Index.aspx?id=ProductManager" title="Products" description="">
<siteMapNode url="~/Index.aspx?id=EditProduct" title="Add Product" description="" />
</siteMapNode>
<siteMapNode url="~/Index.aspx?id=Attributes" title="Variations" description="">
<siteMapNode url="~/Index.aspx?id=AddEditVariation" title="Add/Edit Variations" description="" />
</siteMapNode>
<siteMapNode url="~/Index.aspx?id=GiftCertificateManager" title="Generate Gift Cards" description="" />
<siteMapNode url="~/Index.aspx?id=DepartmentManager" title="Departments" description="">
<siteMapNode url="~/Index.aspx?id=AddEditDepartment" title="Add/Edit Department" description=""/>
</siteMapNode>
<siteMapNode url="~/Index.aspx?id=ManufacturerManager" title="Manufacturers" description="" >
<siteMapNode url="~/Index.aspx?id=AddEditManufacturer" title="Add Manufacturer" description="" />
</siteMapNode>
<siteMapNode url="~/Index.aspx?id=WarehouseManager" title="Warehouses" description="">
<siteMapNode url="~/Index.aspx?id=EditWarehouse" title="Add Warehouse" description="" />
</siteMapNode>
</siteMapNode>
Telerik菜单还有一个XML
<?xml version="1.0" encoding="utf-8" ?>
<PanelItems>
<PanelItem Text="Dashboard" NavigateUrl="../Index.aspx?id=Home"></PanelItem>
<PanelItem Text="Catalog Management" NavigateUrl="../Index.aspx?id=CategoryHome&category=CatalogManagement"> <!-- -->
<PanelItem Text="Products" NavigateUrl="../Index.aspx?id=ProductManager"/> <!-- Product Manager -->
<PanelItem Text="Variations" NavigateUrl="../Index.aspx?id=Attributes"/>
<PanelItem Text="Generate Gift Cards" NavigateUrl="../Index.aspx?id=GiftCertificateManager"/> <!-- Gift Certificate Manager -->
<PanelItem Text="Departments" NavigateUrl="../Index.aspx?id=DepartmentManager"/> <!-- Department Manager -->
<PanelItem Text="Manufacturers" NavigateUrl="../Index.aspx?id=ManufacturerManager"/> <!-- Manufacturer Manager -->
<PanelItem Text="Warehouses" NavigateUrl="../Index.aspx?id=WarehouseManager"/> <!-- Warehouse Manager -->
</PanelItem>
<PanelItem Text="Customer Management" NavigateUrl="../Index.aspx?id=CategoryHome&category=CustomerManagement"> <!-- -->
<PanelItem Text="Customers" NavigateUrl="../Index.aspx?id=CustomerManager" />
<PanelItem Text="Export Subscribers" NavigateUrl="../Index.aspx?id=ExportSubscriptions"/> <!-- Export Subscribers -->
</PanelItem>
<PanelItem Text="Order Management" NavigateUrl="../Index.aspx?id=CategoryHome&category=OrderManagement"> <!-- -->
<PanelItem Text="Orders" NavigateUrl="../Index.aspx?id=FindOrders" /> <!-- Find Orders -->
<PanelItem Text="Shopping Carts" NavigateUrl="../Index.aspx?id=CartView"/> <!-- View Cart -->
<PanelItem Text="Wish Lists" NavigateUrl="../Index.aspx?id=ViewWishList"/> <!-- View Wish List -->
</PanelItem>
还有一个是我正在为5个菜单使用5个资源文件
如何将XML转换为资源
答案 0 :(得分:1)
我不知道我是否完全理解这个问题。如果您想要使用这些XML而不是将它们与您的应用程序一起部署,以将它们作为程序集中的资源,那么您需要执行以下操作:
现在,您的XML作为资源嵌入到程序集中。现在的问题是如何访问它。为此,请使用以下代码:
Assembly assembly = Assembly.GetExecutingAssembly();
Stream stream = assembly.GetManifestResourceStream("<default namespace.>MyFile.xml");
StreamReader streamReader = new StreamReader(stream);
// now process the stream the way you want -- for example streamReader.ReadToEnd() to get it as a text
有一篇名为Embedded resources的好CodeProject文章。