从xml文件取值

假设有个 test.xml,包含以下字段:

1 <config>
2         <property name="login_protocol" value="http" />
3         <property name="access_control" value="10"/>
4         <property name="receipt_route_kbn" value="smartphone_site"/>
5         <property name="fee_kbn" value="i_mode"/>
6         <property name="debug" value="true"/>
7         <property name="iplist_cache_interval" value="1800" />
8 </config>

在java文件中,获取 login_protocol 对应的 value:

1 ...
2
3 String login_protocal = "";
4
5 Config test = Config.getInstance("test.xml");
6
7 login_protocal = test.getProperty("login_protocal");
8
9 ...

原文地址:https://www.cnblogs.com/guojia314/p/9887282.html

时间: 2024-08-03 17:06:47

从xml文件取值的相关文章

Xml文件保存值不能及时更新

今天在Xml文件中修改了一个值,调试时,发现读取的不是最新值.经过各种调试,还是不能解决.只好把文件项目给编译了一遍,在调试时,把在及时窗口,把变量值给改了一下啊,就是可以读到最新配置了.停止程序,在次启动调试,发现也是新值,在刷新了几次,发现还是一直都没问题.XMl利弊兼有啊.以后修改Xml文件了,全部编译才是王道,不然总是有莫名其妙的问题.再次申明啊,要小心啊. Xml文件保存值不能及时更新

SpringBoot使用@Value从yml文件取值为空--注入静态变量

SpringBoot使用@Value从yml文件取值为空--注入静态变量 1.application.yml中配置内容如下: pcacmgr:   publicCertFilePath: E:\\pcacmgr\\CerFiles\\xh_public.cer   encPublicCertFilePath: E:\\pcacmgr\\CerFiles\\hjzf_encPublic.cer   encPfxFilePath: E:\\pcacmgr\\CerFiles\\hjzf_encPfx

在properties.xml中定义变量,在application.xml中取值问题

如果为application.xml中的变量赋默认值,同时又在properties.xml中变量赋值,而加载后是取不到properties.xml中的值的问题. 解决这个问题需要加上黑体部分配置: <bean id="sysConfiguration" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">        <property na

c# xml 解析取值

//字符串 string result = "<?xml version=\"1.0\" encoding=\"utf-8\"?><speed><is_success>T</is_success><response><protocol><partner>123456</partner><sign>123456</sign><sign

C#读取XML文件并取值

1.新建XML文件: <?xml version="1.0" encoding="utf-8" ?> <SystemInfo> <Class name="News" desc="文章栏目"> <Item name="NewsInfo" desc="新闻资讯">1</Item> <Item name="MediaC

《android---获取值AndroidManifest.xml中meta-data的value》

hive常用命令 show tables; 列出hive里面所有数据表名 desc userProfile; 显示数据表userProfile的基本表字段及字段type desc extended trackinfo; 显示数据表trackinfo的详细信息,包括字段说明,数据表等 /usr/local/cloud/hive/bin/hive 进入hive数据库 select attribute_name from pms_attribute where attribute_id=21000 a

读取XML文件的指定节点的值 并转换为Item

cmb_State_Send.ItemsSource = null; XmlDocument doc = new XmlDocument(); doc.Load("D:\\模板\\WorkstationState_Config.xml"); //加载Xml文件 XmlElement rootElem = doc.DocumentElement; //获取根节点 XmlNode xn = rootElem.SelectSingleNode("//Workstation[@Nam

TextView在xml文件中加入onClick属性后,clickable值依旧是false的原因。

先看View中是如何定义clickable和onClick的: case com.android.internal.R.styleable.View_clickable: if (a.getBoolean(attr, false)) { viewFlagValues |= CLICKABLE; viewFlagMasks |= CLICKABLE; } break; 上面这段代码是View源码中对clickable属性的定义,缺省值为false. case R.styleable.View_on

Asp.Net 读取xml文件中Key的值,并且过滤掉注释内容代码

/// <summary> /// 读取配置文件keys /// </summary> /// <returns></returns> public string _GetKeys() { string filename = Server.MapPath("/") + @"web.config"; XmlDocument xmldoc = new XmlDocument(); XmlReaderSettings set