易语言xml解析(易语言怎么读入 xml 文件的内容)
本文目录
- 易语言怎么读入 xml 文件的内容
- 易语言xml属性值中出现等号“=”就无法读取
- 易语言读写XML配置文件
- 易语言怎么修改文件属性和修改XML文件的内容
- 易语言如何读取xml文件标签里的内容
- 从ftp上下载每天的xml文件到本地,再解析本地的xml文件中的数据并将其存入sqlserver数据库中
- 易语言读XML文件读不全,望大神解答!!!
易语言怎么读入 xml 文件的内容
之前用java解析过xml,代码和原理告你,自己变通下
原理:
使用DOM读取XML文件
DOM解析XML文件时,会将XML文件的所有内容以文档树方式存放在内存中
代码:
package service;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import medium.Person;
public class DOMPersonService {
public List《Person》 getPers***(InputStream inputStream) throws Throwable{
List《Person》 pers*** = new ArrayList《Person》();
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = documentBuilderFactory.newDocumentBuilder();
Document document = builder.parse(inputStream);
Element root = document.getDocumentElement();
NodeList personNodes = root.getElementsByTagName("person");
for(int i = 0;i 《 personNodes.getLength();i++){
Person person = new Person();
Element personElement = (Element)personNodes.item(i);
person.setId(new Integer(personElement.getAttribute("id")));
NodeList personChilds = personElement.getChildNodes();
for(int j = 0;j 《 personChilds.getLength();j++){
if(personChilds.item(j).getNodeType()==Node.ELEMENT_NODE){
Element childElement = (Element)personChilds.item(j);
if("name".equals(childElement.getNodeName())){
person.setName(childElement.getFirstChild().getNodeValue());
}else if("age".equals(childElement.getNodeName())){
person.setAge(new Short(childElement.getFirstChild().getNodeValue()));
}
}
}
pers***.add(person);
}
return pers***;
}
}
易语言xml属性值中出现等号“=”就无法读取
------------------------XML---------------------------
《?xml version="1.0" encoding="gb2312"?》
《List Name="水电费-"》
《/List》
------------------------XML---------------------------
------------------------E--------------------------
.版本 2
.支持库 EXMLParser
.支持库 spec
.局部变量 xml, XML树
xml.导入 (取运行目录 () + “\xml.xml”)
’调试输出 (子文本替换 (xml.取属性值文本 (“List”, “Name”, ), “-”, “=”, , , 真))
框1.内容 =子文本替换 (xml.取属性值文本 (“List”, “Name”, ), “-”, “=”, , , 真)
xml.释放 ()
------------------------E--------------------------
既然不支持等号,那就做一次简单的替换不就行了。
易语言读写XML配置文件
用支持库的话 比较麻烦 , 最简单的, 就是改后缀, 读入文件 写到文件, 再改回名称就好了
易语言怎么修改文件属性和修改XML文件的内容
open=XXX****
icon=XXX.ico
只是最常见的,open后面是要运行的文件名,icon后面是盘图标名,还可以加上
shell\open=打开(&O)
shell\open\Command=XXX**** 替换右键点击盘时的“打开”
shell\open\Default=1
shell\explore=资源管理器(&X)
shell\explore\Command=XXX**** 替换右键点击盘时的“资源管理器”
xxx是你的文件名,比如说替换为a****,a.ico,如果你的a****里包含图标:
open=a****
icon=a****,1
shell\open=打开(&O)
shell\open\Command=a****
shell\open\Default=1
shell\explore=资源管理器(&X)
shell\explore\Command=a****
易语言如何读取xml文件标签里的内容
除了上面的用xml树类,也可以用“文本_取出中间文本”
如下面例子:
str = "《to》大猫咪《/to》"
cat= 文本_取出中间文本 (str , “《to》”, “《/to》”)
“大猫咪”的值就被取出来了。
从ftp上下载每天的xml文件到本地,再解析本地的xml文件中的数据并将其存入sqlserver数据库中
我给你个解析的代码吧~具体存数据库得根据实际情况来
#include "StdAfx.h"
#include "parse.h"
#include 《string》
#include "stdafx.h"
#include 《libxml/parser.h》
#include 《libxml/tree.h》
#include 《iostream》
#include 《libxml/xpath.h》
#include 《libxml/xpathInternals.h》
#include 《stdio.h》
#include 《stdlib.h》
#include《windows.h》
using namespace std;
parse::parse()
//int parse::par***ml()
{
xmlDocPtr doc; //定义解析文档指针
xmlNodePtr curNode; //定义结点指针(你需要它为了在各个结点间移动)
xmlChar *szKey; //临时字符串变量
char *szDocName;
doc = xmlReadFile("SimACQ_Config.xml","GB2312",XML_PARSE_RECOVER); //解析文件
//检查解析文档是否成功,如果不成功,libxml将指一个注册的错误并停止。
if (NULL==doc)
{
fprintf(stderr,"Document not parsed successfully. /n");
/*return -1;*/
}
curNode = xmlDocGetRootElement(doc); //确定文档根元素
/*检查确认当前文档中包含内容*/
if (NULL == curNode)
{
fprintf(stderr,"empty document/n");
xmlFreeDoc(doc);
/*return -1;*/
}
/*在这个例子中,我们需要确认文档是正确的类型。“root”是在这个示例中使用文档的根类型。*/
if (xmlStrcmp(curNode-》name, BAD_CAST "SIMCONFIG"))
{
fprintf(stderr,"document of the wrong type, root node != mail");
xmlFreeDoc(doc);
/*return -1; */
}
curNode = curNode-》xmlChildrenNode;
xmlNodePtr propNodePtr = curNode;
while(curNode != NULL)
{
//取出节点中的内容
if ((!xmlStrcmp(curNode-》name, (c***t xmlChar *)"ComConfig")))
{
xmlNodePtr comConfigPtr= curNode-》children;
while(comConfigPtr!=NULL)
{
if((!xmlStrcmp(comConfigPtr-》name,(c***t xmlChar *)"DMS")))
{
xmlChar* szAttr = xmlGetProp(comConfigPtr,BAD_CAST "IP");
IP=(char*)szAttr;
szAttr=xmlGetProp(comConfigPtr,BAD_CAST "PORT");
PORT=atoi((c***t char *)szAttr);
szAttr=xmlGetProp(comConfigPtr,BAD_CAST "TIMEOUT");
TIMEOUT=atoi((c***t char *)szAttr);
xmlFree(szAttr);
}
comConfigPtr=comConfigPtr-》next;
}
}
if ((!xmlStrcmp(curNode-》name, (c***t xmlChar *)"Log")))
{
xmlChar* szAttr = xmlGetProp(curNode,BAD_CAST "Flag");
if(szAttr!=NULL)
{
if((!xmlStrcmp(szAttr,(c***t xmlChar *)"True")))
{
FLAG=true;
}
else
{
FLAG=false;
}
}
szAttr = xmlGetProp(curNode,BAD_CAST "Path");
if(szAttr!=NULL)
{
PATH=(char*)szAttr;
}
xmlFree(szAttr);
}
if ((!xmlStrcmp(curNode-》name, (c***t xmlChar *)"DMS")))
{
xmlChar* szAttr = xmlGetProp(curNode,BAD_CAST "Cache");
if(szAttr!=NULL)
{
Cache=atoi((c***t char *)szAttr);
}
xmlFree(szAttr);
}
if ((!xmlStrcmp(curNode-》name, (c***t xmlChar *)"SimFile")))
{
xmlChar* szAttr = xmlGetProp(curNode,BAD_CAST "Type");
if(szAttr!=NULL)
{
if((!xmlStrcmp(szAttr,(c***t xmlChar *)"PlainFilm")))
{
xmlNodePtr FileNodes=curNode-》children;
int i=0;
while(FileNodes!=NULL)
{
if((!xmlStrcmp(FileNodes-》name,(c***t xmlChar *)"FILE")))
{
szAttr = xmlGetProp(FileNodes,BAD_CAST "name");
if(szAttr!=NULL)
{
/*SIM_PLAIN.Name=(char*)szAttr;*/
strcpy(simulation.SIM_PLAIN.Name,(char*)szAttr);
}
szAttr=xmlGetProp(FileNodes,BAD_CAST "sliceNum");
if(szAttr!=NULL)
{
simulation.SIM_PLAIN.Num=atoi((char*)szAttr);
}
i++;
}
FileNodes=FileNodes-》next;
}
xmlFree(FileNodes);
simulation.SIM_PLAIN.flag=0;
}
if((!xmlStrcmp(szAttr,(c***t xmlChar *)"Spiral"))){
xmlNodePtr FileNodes=curNode-》children;
int i=0;
while(FileNodes!=NULL)
{
if((!xmlStrcmp(FileNodes-》name,(c***t xmlChar *)"FILE")))
{
szAttr = xmlGetProp(FileNodes,BAD_CAST "name");
if(szAttr!=NULL)
{
/*SIM_SPIRAL.Name=(char*)szAttr;*/
strcpy(simulation.SIM_SPIRAL.Name,(char*)szAttr);
}
szAttr=xmlGetProp(FileNodes,BAD_CAST "sliceNum");
if(szAttr!=NULL)
{
simulation.SIM_SPIRAL.Num=atoi((char*)szAttr);
}
i++;
}
FileNodes=FileNodes-》next;
}
xmlFree(FileNodes);
simulation.SIM_SPIRAL.flag=0;
}
if((!xmlStrcmp(szAttr,(c***t xmlChar *)"axial")))
{
xmlNodePtr FileNodes=curNode-》children;
int i=0;
while(FileNodes!=NULL)
{
if((!xmlStrcmp(FileNodes-》name,(c***t xmlChar *)"FILE")))
{
szAttr = xmlGetProp(FileNodes,BAD_CAST "name");
if(szAttr!=NULL)
{
/* SIM_AXIAL.Name=(char*)szAttr;*/
strcpy(simulation.SIM_AXIAL.Name,(char*)szAttr);
}
szAttr=xmlGetProp(FileNodes,BAD_CAST "sliceNum");
if(szAttr!=NULL)
{
simulation.SIM_AXIAL.Num=atoi((char*)szAttr);
}
i++;
}
FileNodes=FileNodes-》next;
}
xmlFree(FileNodes);
simulation.SIM_AXIAL.flag=0;
}
}
xmlFree(szAttr);
}
curNode = curNode-》next;
}
xmlFreeDoc(doc);
/*return 0;*/
}
有什么不明白的再问吧!
易语言读XML文件读不全,望大神解答!!!
把超级列表框换成“高级表格”试试,可能是控件本身的容纳能力吧。没试过那么大的数据。
更多文章:
sharepoint用户权限(sharepoint2010文件夹能设置权限吗,不同文件夹,访问的用户不同)
2026年3月28日 12:20
sql isnull(sql语句 isnull(列名,’’)=’’ 的意思 含义)
2026年3月28日 11:40






