如何使用(c#)识别XML文件中的重复值?

时间:2017-02-06 05:49:07

标签: c# .net

您好我有如下XML文件。我需要检查里面的重复值,如果找到任何重复,那么我需要触发它存在的通知邮件。内部文本对于整个XML文件必须是唯一的。

从下面的文件我有2个值(内部文本)是相同的。那么我如何编写代码来识别这些重复并使用(c#)触发通知邮件。示例代码将非常明显。

<?xml version="1.0" encoding="utf-8"?>
<JobsMapper>
    <Platform>
        <Platform_Data Name="GLP" ServerName="Lydsyd119" Input_Location="\\10.51.226.65\FTK_Production\IO\FileWatcherIO\GLP\GLP\"/>
        <External_Delete_Request InstanceName="archive" DestinationFolder="\\10.51.226.65\FTK Production Release\FTK_Production\IO\FabricationIO\ExternalDeleteRequest\ExternalDelete\INPUT\"/>
        <Archival InstanceName="archive" DestinationFolder="\\10.51.226.65\FTK_Production\IO\FabricationIO\Archive\BundleArchive\INPUT\"/>
        <Job InstanceName="0018" DestinationFolder="\\10.51.226.65\FTK_Production\IO\FabricationIO\0018\MixedContent\INPUT\">
            <DPSI>0018</DPSI>
        </Job>
        <Job InstanceName="0019" DestinationFolder="\\10.51.226.65\FTK_Production\IO\FabricationIO\0019\MixedContent\INPUT\">
            <DPSI>0019</DPSI>
        </Job>  
        <Job InstanceName="0CPN" DestinationFolder="\\10.51.226.65\FTK_Production\IO\FabricationIO\0CPN\MixedContent\INPUT\">
            <DPSI>0CPN</DPSI>
        </Job>
        <Job InstanceName="0011" DestinationFolder="\\10.51.226.65\FTK_Production\IO\FabricationIO\0011\MixedContent\INPUT\">
            <DPSI>0011</DPSI>
        </Job>  
        <Job InstanceName="0011" DestinationFolder="\\10.51.226.65\FTK_Production\IO\FabricationIO\0011\MixedContent\INPUT\">
            <DPSI>0011</DPSI>
        </Job>      
        <Job InstanceName="000S" DestinationFolder="\\10.51.226.65\FTK_Production\IO\FabricationIO\000S\MixedContent\INPUT\">
            <DPSI>000S</DPSI>
        </Job>
        <Job InstanceName="06JW" DestinationFolder="\\10.51.226.65\FTK_Production\IO\FabricationIO\06JW\MixedContent\INPUT\">
            <DPSI>06JW</DPSI>
        </Job>
        <Job InstanceName="0N2Z" DestinationFolder="\\10.51.226.65\FTK_Production\IO\FabricationIO\0N2Z\MixedContent\INPUT\">
            <DPSI>0N2Z</DPSI>
        </Job>  
        <Job InstanceName="0HNQ" DestinationFolder="\\10.51.226.65\FTK_Production\IO\FabricationIO\0HNQ\MixedContent\INPUT\">
            <DPSI>0HNQ</DPSI>
        </Job>  
        <Job InstanceName="000Z" DestinationFolder="\\10.51.226.65\FTK_Production\IO\FabricationIO\000Z\MixedContent\INPUT\">
            <DPSI>000Z</DPSI>
        </Job>
        <Job InstanceName="000W" DestinationFolder="\\10.51.226.65\FTK_Production\IO\FabricationIO\000W\MixedContent\INPUT\">
            <DPSI>000W</DPSI>
        </Job>
        <Job InstanceName="0014" DestinationFolder="\\10.51.226.65\FTK_Production\IO\FabricationIO\0014\MixedContent\INPUT\">
            <DPSI>0014</DPSI>
        </Job>
        </Platform>
        </JobsMapper>

1 个答案:

答案 0 :(得分:0)

以下代码将告诉您有多少节点具有重复值。

<RelativeLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/content_spare_request"
        android:background="#fff"
        android:layout_marginBottom="20dp"
        android:layout_margin="10dp"
        android:layout_below="@+id/root1">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginLeft="5dp"
            android:id="@+id/spare_text"
            android:layout_marginStart="2sp"
            android:paddingLeft="10dp"
            android:layout_marginTop="07dp"
            android:text="@string/Spare"
            android:textAppearance="?android:attr/textAppearanceLarge"
            android:textColor="@color/SForange"
            android:textSize="16sp" />
        <Button
            android:id="@+id/btn_spare"
            android:layout_width="20dp"
            android:layout_height="match_parent"
            android:minHeight="0dp"
            android:minWidth="0dp"
            android:background="@color/SForange"
            android:layout_alignParentRight="true"
            />

        <View
            android:layout_width="match_parent"
            android:layout_height="3dp"
            android:id="@+id/view2"
            android:layout_below="@+id/spare_text"
            android:background="@color/SForange"
            android:gravity="center" />
        <android.support.v7.widget.RecyclerView
            android:layout_width="match_parent"
            android:id="@+id/spare_recyclerview"
            android:layout_below="@+id/view2"
            android:layout_height="wrap_content"/>
        <TextView
            android:id="@+id/empty_view"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:paddingBottom="75dp"
            android:gravity="center_horizontal"
            android:layout_below="@+id/view2"
            android:visibility="visible"
            android:text="No Data Available"
            />

    </RelativeLayout>