Data summary reading XML node

xiaoxiao2021-03-06  57

/ * Read XML data in XML mode * /

something

Something

/ * The first method * / ds.readxml ("Your XMLFile Name");

Container.DataItem ("bb");

Container.DataItem ("cc");

DS.Readxmlschema ("Your XMLFile Name");

/*The second method*/

If I want to find 123, then I should write 321?

USING SYSTEM.XML;

XmlDataDocument Xmldoc = new system.xml.xmldataDocument ();

XMLDoc.Load (@ "c: /config.xml");

XMLELEMENT ELEM = XMLDoc.GetElementByid ("add");

String str = elem.attributes ["value"]. Value

/ * The third method:

Selectsinglenode reads the XML * --- /

-------------------------------------------------- ------------------

Data Source = yf; user ID = CTM_DBO; password = 123 ------------------------------------------------- -------------------------

XmLDocument Doc = New XmLDocument ();

Doc.Load (strxmlname);

XMLNode node = doc.selectsinglenode ("/ configuration / appsettings / connectionstring");

IF (Node! = NULL)

{

String k1 = node.value;

// null

String k2 = node.innertext;

// data source = yf; user ID = CTM_DBO; Password = 123

String k3 = node.innerxml;

// data source = yf; user ID = CTM_DBO; Password = 123

Node = NULL;

}

*********************************************************** ******************

< / appsettings> ** ----------------------------------------- --------------------------- **

XMLNode node = doc.selectsinglenode ("/ configuration / appsettings / add");

IF (Node! = NULL)

{

String k = node.attributes ["key"]. Value;

String v = node.attributes ["value"]. Value;

Node = NULL;

}

* ------------------------------------------------- ------------------- *

XMLNode node = doc.selectsinglenode ("/ configuration / appsettings / add");

IF (Node! = NULL)

{

XMLNodeReader NR = New XMLNodeReader (Node);

nr.movetocontent ();

// Check if the current node is a content node. If this node is not a content node, the reader jumps forward to the next content node or file end.

Nr.MovetoAttribute ("Value");

String s = nr.value;

Node = NULL;

}

转载请注明原文地址:https://www.9cbs.com/read-115864.html

New Post(0)