C#ÖжÔXML½Úµã½øÐÐÔöɾ¸Ä²é
ºÅ³ÆxmlhelperµÄÒ»¸öÀà
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Xml;
namespace WebApplication2
{
/// <summary>
/// XMLHelper XMLÎĵµ²Ù×÷¹ÜÀíÆ÷
/// </summary>
public class XMLHelper
{
public XMLHelper()
{
//
// TODO: ÔÚ´Ë´¦Ìí¼Ó¹¹Ô캯ÊýÂß¼
//
}
#region XMLÎĵµ½Úµã²éѯºÍ¶ÁÈ¡
/// <summary>
/// Ñ¡ÔñÆ¥ÅäXPath±í´ïʽµÄµÚÒ»¸ö½ÚµãXmlNode.
/// </summary>
/// <param name="xmlFileName">XMLÎĵµÍêÈ«ÎļþÃû(°üº¬ÎïÀí·¾¶)</param>
/// <param name="xpath">ҪƥÅäµÄXPath±í´ïʽ(ÀýÈç:"//½ÚµãÃû//×Ó½ÚµãÃû")</param>
/// <returns>·µ»ØXmlNode</returns>
public static XmlNode GetXmlNodeByXpath(string xmlFileName, string xpath)
{
XmlDocument xmlDoc = new XmlDocument();
try
{
xmlDoc.Load(xmlFileName); //¼ÓÔØXMLÎĵµ
XmlNode xmlNode = xmlDoc.SelectSingleNode(xpath);
return xmlNode;
}
catch (Exception ex)
{
return null;
//throw ex; //ÕâÀï¿ÉÒÔ¶¨ÒåÄã×Ô¼ºµÄÒì³£´¦Àí
}
}
/// <summary>
/// Ñ¡ÔñÆ¥ÅäXPath±í´ïʽµÄ½ÚµãÁбíXmlNodeList.
/// </summary>
/// <param name="xmlFileName">XMLÎĵµÍêÈ«ÎļþÃû(°üº¬ÎïÀí·¾¶)</param>
/// <param name="xpath">ҪƥÅäµÄXPath±í´ïʽ(ÀýÈç:"//½ÚµãÃû//×Ó½ÚµãÃû")</param>
/// <returns>·µ»ØXmlNodeList</returns>
public static XmlNodeList GetXmlNodeListByXpath(string xmlFileName, string xpath)
{
XmlDocument xmlDoc = new XmlDocument();
try
{
xmlDoc.Load(xmlFileName); //¼ÓÔØXMLÎĵµ
XmlNodeList xmlNodeList = xmlDoc.SelectNodes(xpath
Ïà¹ØÎĵµ£º
ÓÉÓÚÐèҪʵÏÖÒÔϹ¦ÄÜ£º
Íø¹ØÍ¨¹ý´®¿Ú·¢ËÍÊý¾Ý¸øPC»ú£¬PC»úÊÕ¼¯Êý¾Ý²¢½âÎö±£´æµ½MySQLÖУ¬È»ºóJSPÒ³Ãæ¶ÁÈ¡MySQLÖеÄÊý¾Ý²¢ÏÔʾ¡£
ËùÒÔÀûÓÃC#Á¬½ÓMySQLÊý¾Ý³ÉΪÁ˱ØÐëÒª¾¹ýµÄ¹ý³Ì£¬Ôڴ˸øÓèÏêϸµÄ˵Ã÷¡£
1¡¢ÏÂÔØÐèÒªµÄÎļþMySQLDriverCS£¬ÏÂÔØµØÖ·Îª£ºhttp://sourceforge.net/projects/mysqldrivercs
2¡¢°²×°Îļþ£ºMySQ ......
Óà PHP ¶ÁÈ¡ºÍ±àд XML DOM
ʹÓà DOM ¿â¡¢SAX ½âÎöÆ÷ºÍÕýÔò±í´ïʽ
ÎĵµÑ¡Ïî
´òÓ¡±¾Ò³
½«´ËÒ³×÷Ϊµç×ÓÓʼþ·¢ËÍ
¼¶±ð£º Öм¶
Jack Herrington (jack_d_herrington@codegeneration.net), ¸ß¼¶Èí¼þ¹¤³Ìʦ, "Code Generation Network"
2006 Äê 2 ÔÂ 06 ÈÕ
ÓÐÐí¶à¼¼Êõ¿ÉÓÃÓÚÓà PHP ¶ÁÈ¡ºÍ±àд XML¡£±¾ÎÄÌṩÁËÈýÖÖ ......
<!-- xml¸ñʽ
<foo xmlns="test">
<bar attr='a'></bar>
<bar attr='b'></bar>
<bar attr='c'></bar>
</foo>
-->
<?php
$dom = new DOMDocument();
if (!$dom->load('attr.xml'))
{
echo "load books.xml failed!<br>";
re ......
½øÈëMyEclipse6.XÏÂ
Ð޸ģºeclipse.ini Îļþ
-Duser.language=en
¸Ä³É
-Duser.language=zh
µ¯³öÌáʾ£ºCtrl+"/"
dtd ÃüÃû¿Õ¼äµÄÌáʾÐÅÏ¢
window-->Preference-->xml-->XML Catalog-->add
Location :sql-map-2.dtd
key type :pubic ID
key:-//ibatis.apache.org//DTD SQL Map 2.0//EN (XMLÎļþÃüÃû¿Õ¼ ......