Linq to XML customize distinct function
Definition comparer class,
class ItemComparer : IEqualityComparer<XElement>
{
public bool Equals(XElement x, XElement y)
{
return x.Attribute("Name").Value == x.Attribute("Name").Value;
}
public int GetHashCode(XElement obj)
{
return obj.Attribute("Name").Value.GetHashCode();
}
}
How to use this one to distinct:
public List<string> LoadDistrict(string region)
{
if (m_DataDoc == null)
return null;
List<string> list = new List<string>();
try
{
var query = from r in m_DataDoc.Elements("DashBoardData").Elements("LevelData").Elements("Region").Where(a => a.Attribute("Name").Value.ToLower() == region.ToLower())
select r;
foreach (var district in query.Elements("District").Distinct(new ItemComparer()))
{
list.Add(district.Attribute("Name").Value);
}
return list;
}
catch (Exception exp)
{
MessageBox.Show(exp.Message);
return null;
}
}
Ïà¹ØÎĵµ£º
±¾ÎÄ×ܽáÁËÔÚPythonÖÐÖ÷ÒªµÄ¼¸ÖÖ´¦ÀíXMLµÄ·½·¨£º
Element Tree
SAX
Dom
ʹÓõÚÈý·½Àà¿âÈçAmara 2.x£¬ libxml2dom µÈ
Element Tree
Element TreeÊÇPython 2.5ÒýÈëµÄʹÓüòµ¥£¬¿ì½ÝµÄ´¦Àí·½·¨£¬ Ò²ÊÇPython±ê×¼Àà¿âÍƼöµÄ´¦ÀíXMLµÄ·½·¨¡£
ËüʹÓÃÊ÷ÐνڵãµÄÐÎʽÀ´¶ÁдXML¡£Element TreeÊÇÇáÁ¿¼¶µÄDOM£¬ ËùÒÔÊ ......
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
create procedure [dbo].[MachiningPayedGetListByCondition]
@CustomerName varchar(50),
@CustomerPhone varchar(50),
@PactNumber varchar(50),
@Ispay bit
as
begin
set nocount on;
SELECT
dp.ID as 'MachiningPayed/@ID',
&nbs ......
1.½âÊÍ
ÒòΪjspÓõ½ÁËSiteDataÀ࣬¶øSiteData¼Ì³ÐBasePageÀ࣬
ËùÒÔBasePage¹¹Ô캯Êý
BasePage¹¹Ô캯Êý
initializeByCityCodeº¯Êýmain
keyµÄÖµmain.UpImages
vµÄÖµmain.UpImages
2.Ö´ÐÐÍê BasePage.java
ÖеÄinitCommon()ºó£¬
Ìøµ½SiteData.java ÖÐµÄ process();·½·¨£¬
public SiteData(HttpServletR ......
Android ÊÇÕë¶ÔÒƶ¯É豸µÄÒ»ÖÖÐÂÐ˵ĿªÔ´²Ù×÷ϵͳºÍ SDK¡£½èÖúËü£¬Äú¿ÉÒÔ´´½¨¹¦ÄÜÇ¿´óµÄÒƶ¯Ó¦ÓóÌÐò¡£µ±ÄúµÄÓ¦ÓóÌÐò¿ÉÒÔ·ÃÎÊ Web ·þÎñʱ£¬ÆäÎüÒýÁ¦»á´ó´óÔö¼Ó£¬ÕâÒâζ×ÅÄúÐèҪʹÓà Web ÓïÑÔ£ºXML¡£ÔÚ±¾ÎÄÖУ¬Äú½«Á˽âÔÚ Android ÉÏʹÓà XML µÄ²»Í¬·½·¨£¬ÒÔ¼°ÈçºÎʹÓÃËüÃǹ¹½¨×Ô¼ºµÄ Android Ó¦ÓóÌÐò¡£
ÈëÃÅ
ÔÚ±¾ÎÄÖÐ ......