VB6.0如何读取并修改XML文件?

VB6.0如何读取并修改XML文件?,第1张

你有两个选择:

1、将xml文件当做文本文件来处理。替换指定字符即可。

2、使用 MSXML 组件来处理。度娘搜一下,一大堆文档可参考。

打字不易,如满意,望采纳。

import javaioFile;

import javaxxmlparsersDocumentBuilder;

import javaxxmlparsersDocumentBuilderFactory;

import orgw3cdomDocument;

import orgw3cdomElement;

import orgw3cdomNodeList;

public class Xml {

public static void main(String[] args) {

try {

DocumentBuilderFactory factory = DocumentBuilderFactory

newInstance();

DocumentBuilder builder = factorynewDocumentBuilder();

Document document = builderparse(new File("E:\\新建 文本文档 (3)xml"));

Element rootElement = documentgetDocumentElement();

NodeList list = rootElementgetElementsByTagName("Header");

Element element = (Element) listitem(0);

Systemoutprintln(elementgetChildNodes()item(0)getNodeValue());

} catch (Exception e) {

Systemoutprintln("exception:" + egetMessage());

}

}

}

我项目里面用到的,第一个是读取,下面一个是写入和更改。

protected void BindSetting()

{

DataSet ds = new DataSet();

dsReadXml(ServerMapPath("~/Setting/Score_Settingsxml"));

DataRow dr = dsTables["Setting"]Rows[0];

TextBoxRegScoreText = dr["RegScore"]ToString();

TextBoxPerfectScoreText = dr["PerfectScore"]ToString();

TextBoxMemberCardScoreText = dr["MemberCardScore"]ToString();

TextBoxDevelopMemberScoreText = dr["DevelopMemberScore"]ToString();

TextBoxShopScoreText = dr["ShopScore"]ToString();

TextBoxSendScoreText = dr["SendScore"]ToString();

TextBoxGroupBuyActivityScoreText = dr["GroupBuyActivityScore"]ToString();

TextBoxBirthdayScoreText = dr["BirthdayScore"]ToString();

TextBoxFeastScoreText = dr["FeastScore"]ToString();

}

protected void ButtonEdit_Click(object sender, EventArgs e)

{

DataSet ds = new DataSet();

dsReadXml(ServerMapPath("~/Setting/Score_Settingsxml"));

DataRow dr = dsTables["Setting"]Rows[0];

dr["RegScore"] = TextBoxRegScoreText;

dr["PerfectScore"] = TextBoxPerfectScoreText;

dr["MemberCardScore"] = TextBoxMemberCardScoreText;

dr["DevelopMemberScore"] = TextBoxDevelopMemberScoreText;

dr["ShopScore"] = TextBoxShopScoreText;

dr["SendScore"] = TextBoxSendScoreText;

dr["GroupBuyActivityScore"] = TextBoxGroupBuyActivityScoreText;

dr["BirthdayScore"] = TextBoxBirthdayScoreText;

dr["FeastScore"] = TextBoxFeastScoreText;

dsWriteXml(ServerMapPath("~/Setting/Score_Settingsxml"));

dsAcceptChanges();

}

DABAN RP主题是一个优秀的主题,极致后台体验,无插件,集成会员系统
网站模板库 » VB6.0如何读取并修改XML文件?

0条评论

发表评论

提供最优质的资源集合

立即查看 了解详情