Understanding: XML has several verification methods, DTD and mode. That is, the pattern is used to verify whether the XML meets the requirements.
081223
- // Write
- // Dataset DS = oledbhelper. executeds ("select * From userinfo ");
- // Ds. writexml (server. mappath (@"~ /Xmlstudy/") +" 123.xml ");
- // Read
- Dataset DS = new dataset ();
- DS. readxml (server. mappath (@"~ /Xmlstudy/") +" 123.xml ");
081222
Boyi helps implement a small function
- Xmldocument Doc = new xmldocument ();
- Doc. Load (@ "../test. xml"); // load the XML document
- Xmlnode root = Doc. documentelement; // get the document root node
- If (root. haschildnodes)
- {
- Xmlnode ELEM = Doc. createnode (xmlnodetype. element, "category", null );
- String XPath = "Descendant: level-1 node [/root node/level-1 node [name = 'tree']";
- Xmlnodelist xnlist = Doc. selectnodes (XPath );
- Foreach (xmlnode item in xnlist)
- {
- ELEM. appendchild (item );
- }
- Root. prependchild (ELEM );
- Doc. Save (@ "../test. xml ");
- Console. Write (Doc. innerxml );
- }
- <? XML version = "1.0" encoding = "UTF-8"?>
- <Root node>
- <Category>
- <Level 1 node id = "001">
- <Name> tree </Name>
- <Sex> male </sex>
- </Primary node>
- <Level 1 node id = "002">
- <Name> Boyi </Name>
- <Sex> female </sex>
- </Primary node>
- </Category>
- </Root node>
- <! -- Modified data
- <Root node>
- <Level 1 node id = "001">
- <Name> tree </Name>
- <Sex> male </sex>
- </Primary node>
- <Level 1 node id = "002">
- <Name> Boyi </Name>
- <Sex> female </sex>
- </Primary node>
- </Root node>
- -->
End