& lt; Kcbpspd>
& lt; Program acm="public" cache="yes" comment="" module=" stkPtwtOderHgqlt concurrence="1" "name=" 100100 "node=" 0 "path=".. \ LBM \ lbm_stk DLL "perfmon=" no "priority=" 1 "RSL=" 1 "servicestate=" enable "servicetime=" "timeout=" 60 "type=" biz "userexitnumber=" "xa=" "/& gt;
& lt; The program acm="public" cache="yes" commet="concurrence"="1" module="rptbsPreCheckHgqltdata" name="100102" node="0" path=".. \ LBM \ lbm_rptbs DLL "perfmon=" no "priority=" 1 "RSL=" 1 "servicestate=" enable "servicetime=" "timeout=" 60 "type=" biz "userexitnumber=" "xa=" "/& gt;
& lt; The program acm="public" cache="yes" comment="concurrence"="1" module="stkGsxwOrderFundStkFrzHgqlt" name="100103" node="0" path=".. \ LBM \ lbm_stk DLL "perfmon=" no "priority=" 1 "RSL=" 1 "servicestate=" enable "servicetime=" "timeout=" 60 "type=" biz "userexitnumber=" "xa=" "/& gt;
& lt; The program acm="public" cache="yes" comment="concurrence"="1" module="stkGsxwOrderFundStkUnfrzHgqlt" name="100104" node="0" path=".. \ LBM \ lbm_stk DLL "perfmon=" no "priority=" 1 "RSL=" 1 "servicestate=" enable "servicetime=" "timeout=" 60 "type=" biz "userexitnumber=" "xa=" "/& gt;
& lt;/kcbpspd>
I want to achieve, in accordance with the name of the program for sorting, ascending and descending order can,
Hope to have a great god can help have a look, is there a right way
CodePudding user response:
Public static void main (String [] args) throws DocumentException {String a="& lt; ? The XML version=\ \ "1.0" encoding=\ "utf-8 "?> \ n + "
"& lt; Kcbpspd> \ n + "
"& lt; The program acm=\ "public " cache=\ "yes " comment=\ "" module=\ "stkPtwtOderHgqlt " concurrence=\ \ "- 1" name=\ \ "100100 " node=\ \ "0" path=\ ".. \ \ LBM \ \ lbm_stk DLL \ "perfmon=" no \ "priority=" 1 \ \ "RSL=" 1 "servicestate=" enable \ "servicetime=" \ "timeout=\ 60 " biz "type=" \ "userexitnumber=\ " xa=\ \ "/& gt; \ n + "
"& lt; The program acm=\ "public " cache=\ "yes " commet=\ "" concurrence=\ \ "- 1" module=\ "rptbsPreCheckHgqltdata " name=\ \ "100102 " node=\ \ "0" path=\ ".. \ \ LBM \ \ lbm_rptbs DLL \ "perfmon=" no \ "priority=" 1 \ \ "RSL=" 1 "servicestate=" enable \ "servicetime=" \ "timeout=\ 60 " biz "type=" \ "userexitnumber=\ " xa=\ \ "/& gt; \ n + "
"& lt; The program acm=\ "public " cache=\ "yes " comment=\ "" concurrence=\ \ "- 1" module=\ "stkGsxwOrderFundStkFrzHgqlt " name=\ \ "100103 " node=\ \ "0" path=\ ".. \ \ LBM \ \ lbm_stk DLL \ "perfmon=" no \ "priority=" 1 \ \ "RSL=" 1 "servicestate=" enable \ "servicetime=" \ "timeout=\ 60 " biz "type=" \ "userexitnumber=\ " xa=\ \ "/& gt; \ n + "
"& lt; The program acm=\ "public " cache=\ "yes " comment=\ "" concurrence=\ \ "- 1" module=\ "stkGsxwOrderFundStkUnfrzHgqlt " name=\ \ "100104 " node=\ \ "0" path=\ ".. \ \ LBM \ \ lbm_stk DLL \ "perfmon=" no \ "priority=" 1 \ \ "RSL=" 1 "servicestate=" enable \ "servicetime=" \ "timeout=\ 60 " biz "type=" \ "userexitnumber=\ " xa=\ \ "/& gt; \ n + "
"& lt;/kcbpspd> ";
Document the Document=DocumentHelper. ParseText (a);
Element rootElement=document. GetRootElement ();
List
Elements. Sort ((e1 and e2) - & gt; E2. AttributeValue (" name "). The compareTo (e1. AttributeValue (" name ")));
The Document retDoc=DocumentHelper. CreateDocument ();
Element addElement=retDoc. AddElement (" KCBPSPD ");
For (Element Element: elements) {
AddElement. Add (Element (Element). The clone ());
}
System. The out. Println (retDoc asXML ());
}
According to the name arranged in reverse chronological order, but I don't suggest you do so, according to the definition of XML, the node itself is no order at the same level
CodePudding user response:
Thank qq_36201564 your reply, sorting is behind in order to achieve two main XML file contrast difference function, after thinking about sorted by the specified attribute can ignore the dislocation such differences, can't think out two XML files contrast differences have what good method, is to ignore the wrong line, and to ignore the difference before and after attribute, Spaces, annotation, etc., and this is just one of the XML file, the content of the XML file is not controllable is too big, thank you for your reply