㈠ 如何通过读取XML配置文件导入Excel文件到数据中
1.首先,我们正常使用Excel的另存为,看看能否顺利地直接另存为XML文件。
方法:
点击Excel左上角按钮,在弹出的选项中,点击“另存为”
或者直接在Excel中按下快捷键F12
㈡ java读取xml配置文件:
import java.io.File;import java.net.MalformedURLException;import java.util.List;import org.dom4j.Document;import org.dom4j.DocumentException;import org.dom4j.Element;import org.dom4j.io.SAXReader;/*test.xml内容<company-config><company id="1" name="hideCompanyMobile">13823095539,111,222</company></company-config>*/public class Demo_01 { public static void main(String[] args) { File inputXml = null; SAXReader saxReader = null; Document document = null; List list = null; try { inputXml = new File("D:/test.xml"); saxReader = new SAXReader(); document = saxReader.read(inputXml); list = document.selectNodes("//company-config/company[@id='1']"); if(list.size()>0){ Element element = (Element)list.get(0); String[] strArray = element.getText().split(","); System.out.println(strArray[0]); System.out.println(strArray[1]); System.out.println(strArray[2]); } } catch (MalformedURLException e) { e.printStackTrace(); } catch (DocumentException e) { e.printStackTrace(); } finally { list = null; document = null; saxReader = null; inputXml = null; } }}
㈢ xml 配置文件嵌套了选择,vb如何对此配置文件读取获得参数
[vb] view plain Public Class CSysXML Dim mXmlDoc As New System.Xml.XmlDocument Public XmlFile As String Public Sub New(ByVal File As String) MyClass.XmlFile = File MyClass.mXmlDoc.Load(MyClass.XmlFile) '加载配置文件 End Sub '功能:取得元素值 '参数:node–节点 element–元素名 '返回:元素值 字符型 ' $–表示出错误 Public Function GetElement(ByVal node As String, ByVal element As String) As String On Error GoTo Err Dim mXmlNode As System.Xml.XmlNode = mXmlDoc.SelectSingleNode("//" + node)
㈣ web.xml中如何读取properties配置文件中的值
方法如下:
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath:/config/log4j.properties</param-value>
</context-param>
㈤ 怎么读取指定的activemq.xml配置文件来
可以使用“xbean”语法,具体是“xbean:配置文件相对路径/配置文件绝对路径”,比如“bin/activemq start xbean:conf/activemq2.xml”,“bin/activemq start xbean:/home/dsl/conf/activemq2.xml”。
㈥ IDEA 无法读取项目的xml配置文件,找不到路径是为什么
1.将所有资源文件放在resources文件夹下这样做很方便,比较容易想到,但是层次性就很差了,比如专mybatis的映射配置文件mapper.xml,本属来需要放在特定的包里面,与层,service层等层次为同一个层级,如今只能放在resource文件夹下,不方便分层;2.如果该项目是maven项目:配置maven的pom文件配置,在pom文件中找到<build>节点,添加下列代码:<build><resources><resource><directory>src/main/java</directory><includes><include>**/*.xml</include></includes></resource></resources></build>我尝试过将directory修改为具体的放置配置文件的包,即修改成 src/main/java/lj/ncepu/mapperXML,然后<include>标签里面也做了很多修改和尝试,始终无法访问到配置文件;
㈦ 如何编写或从XML配置文件中读取
配置文件是XML配置文件(配置) config文件中会有像许多条目<name>abcd</name><company>xyz</company><choise>choise1</choise>
NSIS共有4 XML的插件可供选择; NsisXML(由Wizou).xML插件,NsisXML(乔尔)和NSXML 使用NsisXML(由Wizou):Outfile "$%temp%NSISTest.exe"RequestExecutionLevel userInstalldir "$Temp"Showinstdetails show!include LogicLib.nshPage InstFiles!define XMLFILE "$instdirmyxml.xml"SectionStrCpy $9 "Did not exist"nsisXML::creatensisXML::load "${XMLFILE}"${If} $0 = 0;build a new basic XML file:nsisXML::creatensisXML::createProcessingInstruction "xml" 'version="1.0" encoding="UTF-8" standalone="yes"'nsisXML::appendChildnsisXML::release $2${EndIf}nsisXML::select '/choise'${If} $2 = 0StrCpy $1 $0nsisXML::createElement "choise"nsisXML::appendChild${Else}nsisXML::getTextStrCpy $9 $3${EndIf}DetailPrint "Old value: $9"System::Call 'kernel32::GetTickCount()i.r5' ;Get some "random" value to savensisXML::setText "$5"nsisXML::release $2nsisXML::save "${XMLFILE}"nsisXML::release $0DetailPrint "Saved new value: $5"SectionEnd
在优先次运行我得到:Old value: Did not existSaved new value: 709289703Completed并在第二次运行我得到:Old value: 709289703Saved new value: 709308687Completed
㈧ 如何从XML文件里面读取配置文件
类public string GetConStr(){try{XmlDocument xmlDoc = new XmlDocument();xmlDoc.Load(Server.MapPath("App_Data\\config.xml"));XmlNode node1 = xmlDoc.SelectSingleNode("configuration/ConnectionStrings1/DataSource");XmlNode node2 = xmlDoc.SelectSingleNode("configuration/ConnectionStrings1/uid");XmlNode node3 = xmlDoc.SelectSingleNode("configuration/ConnectionStrings1/pwd");string strcon = "Data Source=" + node1.InnerText + ";uid=" + node2.InnerText + ";pwd=" + node3.InnerText;return strcon;}catch{Response.Redirect("Config.aspx");return null;}}调用IConfig iconfig = new IConfig();iconfig .GetConStr();
㈨ C# XMl读写配置文件
<config><serv_ip>192.168.0.1</serv_ip><connect_time>30</connect_time><refresh_time>60</refresh_time><serv_port>3000</serv_port></config>
一般像这样就行了 很简单的
或者多个配置你可以加个item标签如:
<config><item><serv_ip>192.168.0.1</serv_ip><connect_time>30</connect_time><refresh_time>60</refresh_time><serv_port>3000</serv_port></item><item><serv_ip>192.168.0.2</serv_ip><connect_time>30</connect_time><refresh_time>60</refresh_time><serv_port>3000</serv_port></item></config>
假定文件路径为:path
读取和保存:
usingsystem.xml;XmlDocumentxml=newXmlDocument();//声明xmlxml.Load(path);//按路径读xml文件xmlnoderoot=xml.selectsinglenode("config");//指向根节点xmlnodexn=root.selectsinglenode("serv_ip");//指向根节点下的serv_ip节点stringip=xn.innertext;//读出里面的值注意读取的是string需要类型转换的话自己做//修改:xn.innertext="192.168.2.2";xml.save(path);//保存更改到路径
㈩ python如何使用sax提取xml配置文件内容
#vim info.xml<info><intro>信息</intro><list id='001'><head>auto_userone</head><name>Jordy</name></list></info>#vim infoxmlparser.py#!/usr/bin/python#coding=utf-8#Python Version Python 2.6.5from xml.sax.handler import ContentHandlerfrom xml.sax import parseclass HeadlineHandler(ContentHandler):in_headline=Falsedef __init__ (self):ContentHandler.__init__(self)self.data=[]self.file=open('info.txt','w')self.file.writelines('id'+'\t'+'head\n')self.file.close()def startElement(self,name,attrs):if name == 'list':self.data.append(attrs['id'])if name == 'head':self.in_headline=Truedef endElement(self,name):if name == 'list':self.file=open('info.txt','a')self.file.writelines(self.data[0]+'\t'+self.data[1]+'\n')self.file.close()self.data=[]if name == 'head':self.in_headline=Falsedef characters(self,string):if self.in_headline:self.data.append(string)if __name__=='__main__':parse('info.xml',HeadlineHandler())