Previously, an XML operation was performed. Some of them are vertex values.
The following generation:
Public Dataview getdata ( String Xmlpathnode)
{
// Get XML date, return dataview
Try
{
Stringreader read= NewStringreader (objxmldoc. selectsinglenode (xmlpathnode). outerxml );
DS. readxml (read );
}
Catch
{
Objerror. programerror ();
}
If (Ds. Tables. Count = 0 )
{
Return NewDataview ();
}
Return DS. Tables [ 0 ]. Defaultview;
}
This method is used to retrieve the specified vertex and value in XML data records. Later, I changed my next generation to a friend:
Public Dataview getdata ( String Xmlpathnode)
{
// Get XML date, return dataview
Try
{
// System. Io. stringreader READ = new system. Io. stringreader (objxmldoc. selectsinglenode (xmlpathnode). outerxml );
Xmlnodelist xnl = Objxmldoc. getelementsbytagname (xmlpathnode );
System. Text. stringbuilder strxml = New System. Text. stringbuilder ();
Strxml. append ( " <? XML version = '1. 0'?> <Root> " );
For ( Int I = 0 ; I < Xnl. Count; I ++ )
{
Strxml. append (xnl [I]. outerxml );
}
Strxml. append ( " </Root> " );
System. Io. stringreader read = New System. Io. stringreader (strxml. tostring ());
DS. readxml (read );
}
Catch
{
//
}
Return DS. Tables [ 0 ]. Defaultview;
}
This method is used to retrieve all xmlpathnode vertices and values, regenerate an XML file, and return dataview.
The difference between the two methods is that the former uses the specified vertex and the latter uses all the vertex.