Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

½«XMLÊý¾ÝÌî³äµ½TreeViewÖÐ

Îĵµ¼°´úÂëÏÂÔØ£ºhttp://www.dingos.cn/index.php?topic=1899.0
½éÉÜ

µ±²Ëµ¥ÏîÊǾ­³£¸Ä±äʱ£¬´ÓXMLÎĵµÖд´½¨TreeView²Åµ±ÊǷdz£ÓÐÓõġ£ÀýÈ磬ʹÓÃXML×÷ΪÊý¾Ý¿â´æ´¢¼Ç¼¡£
ÕâÀïÓиö¼òµ¥Ê¾Àý¡£ÒÔ·À»ìÏýÕâ¸öÀý×ӱȽϼòµ¥¡£
±³¾°
¶ÔXML¡¢TreeView¿Ø¼þµÄÓ¦Óã¬ÔÚVisual StudioÖÐÓÐÖúÓÚÀí½âÕâЩ²½Öè¡£
ʹÓôúÂë
×¢Ò⣺Õâ¸ö½â¾ö·½°¸£¨xml2treeviewmenuSolution£©ÊÇVS2010´´½¨¡£
Ìí¼ÓÒ»¸öXMLÎļþµ½ÏîÄ¿Öв¢ÃüÃûΪ“menu.xml”¡£¸ù¾Ý²Ëµ¥Ïî±à¼­XMLÎļþ¡£
<?xml version="1.0" encoding="utf-8" ?>
<root>
<folder title='folder 1a' >
<record title='record 1a1' />
<record title='record 1a2' />
<folder title='folder 1b'>
<record title='record 1b1' />
</folder>
</folder>
<folder title='folder 2a' >
<record title='record 2a1' />
</folder>
<folder title='folder 3a' >
<record title='record 3a1' />
<record title='record 3a2' />
</folder>
</root>

´ÓVisual
Studio¹¤¾ßÏäÖн«TreeView¿Ø¼þÍÏÈëWindows´°ÌåÖС£ÔÚÕâ¸öÀý×Ó£¬ÃüÃû¿Ø¼þΪ“treeViewMenu”¡£Ê¹ÓÃusingÌí¼Ó¶ÔXMLÀàµÄÒýÓá£
using System.Xml;
using System.Xml.XPath;

´´½¨Ò»¸öXMLDocument¶ÔÏóÓÃÓÚ±£´æÎļþ¡£
public partial class Form1 : Form{
private XmlDocument docXML = new XmlDocument();

µ±´°Ìå¼ÓÔØʱ£¬´ÓXMLÎļþÖмÓÔØÌî³äTreeView¿Ø¼þµÄXMLÎĵµ¡£
private void Form1_Load(object sender, EventArgs e){
docXML.Load("menu.xml"); // ¼ÓÔØXMLÎļþ
populateBaseNodes(); // Ìî³äËùÓиù½Úµã
}
´ÓµÚÒ»¼¶<folder>½Úµã¿ªÊ¼Ìî³ä¡£½«Ã¿¸ö¸ù½ÚµãÌí¼Óµ½Ê÷ÖУ¬²¢Îªµ±Ç°¸ù¾ÝµãÌí¼Ó×ӽڵ㡣
private void populateBaseNodes(){
treeViewMenu.Nodes.Clear(); // Çå³þÒÑ´æÔÚµÄÏî
treeViewMenu.BeginUpdate(); // ¿ªÊ¼¸üÐÂTreeView
TreeNode treenode;
treenode = treeViewMenu.Nodes.Add("Folders");
XmlNodeList baseNodeList = docXML.SelectNodes("root/folder");
// »ñµÃµÚÒ»²ã <folder> ½Úµã
foreach (XmlNode xmlnode in baseNodeList){
// ±äÁ¿ËùÓеĸù½Úµã <


Ïà¹ØÎĵµ£º

¡¾C#¡¿XSLTת»»XMLʵÀý

²úÆ·¼¸ÄêǰʹÓÃASP£¬ºóÀ´Éý¼¶µ½.Net 1.1£¬ÔÙÉý¼¶µ½2.0£¬Ò»Ö±¶¼ÓÐÓÃXSLTת»»XMLÉú³ÉÍøÒ³µÄ·½Ê½£¬ÉÔ΢ÕûÀíÏ¡£
    XML file:
<?xml version="1.0" encoding="utf-8" ?>
<ric>
  <catalog>
    <book price ......

10¸ö·½ÃæÃèдXMLÎļþ¸ñʽµÄÌصã(ת)

1. ¾ßÓÐÁ¼ºÃµÄ¸ñʽ
XML Îĵµ¸ñʽÊôÓÚÁ¼ºÃ¸ñʽµÄÎļþ¡£HTML ÎļþÖеıê¼Ç£¬ÓÐЩÊDz»ÐèÒª½áβ±ê¼ÇµÄ£¬Èç<br>£¬ÓÐЩÍøҳȱÉÙÈô¸É½áβ±ê¼Ç£¬ÕÕÑùÄÜÕýÈ·ÏÔʾ¡£¶øXML µÄ±ê¼ÇÒ»¶¨ÒªÓµÓнáβ±ê¼Ç£¬ÀýÈ磺
<name>ÕÅÈý</name>
¼´£¬XML ±ê¼ÇÒ»¶¨ÊdzÉË«³É¶ÔµÄ¡£Èç¹ûûÓнáβ±ê¼Ç£¬ÄÇôÔÚ½áÊøµÄ“>”Ç ......

javascript¼ÓÔØxmlÎļþ

<mce:script language="javascript" type="text/javascript"><!--
//ÐèÒª¶ÁÈ¡µÄxmlÎļþ
var uRl = "jsReadXml.xml";
var xmlDoc;
//³õʼ»¯£¬¸øÉÏÊö¶¨Òå±äÁ¿¸³Öµ
// function showcurcity(){
if(window.ActiveXObject)
{
xmlDoc=new ActiveXObject("Microsoft.XMLDOM&q ......

ʹÓÃDOM4JºÍxpath½âÎöXML£¨Ò»£©

books.xml:
Xml´úÂë
<?xml version="1.0" encoding="UTF-8"?>  
<books>  
    <!--This is a test for dom4j, jakoes, 2007.7.19-->  
    <book show="yes"  ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ