×

易语言xml解析

易语言xml解析(易语言如何读取xml文件标签里的内容)

admin admin 发表于2024-04-21 12:35:08 浏览19 评论0

抢沙发发表评论

各位老铁们好,相信很多人对易语言xml解析都不是特别的了解,因此呢,今天就来为大家分享下关于易语言xml解析以及易语言如何读取xml文件标签里的内容的问题知识,还望可以帮助大家,解决大家的一些困惑,下面一起来看看吧!

本文目录

易语言如何读取xml文件标签里的内容

除了上面的用xml树类,也可以用“文本_取出中间文本”如下面例子:str = "《to》大猫咪《/to》"cat= 文本_取出中间文本 (str , “《to》”, “《/to》”)“大猫咪”的值就被取出来了。

易语言读写XML配置文件

用支持库的话 比较麻烦 , 最简单的, 就是改后缀, 读入文件 写到文件, 再改回名称就好了

易语言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--------------------------既然不支持等号,那就做一次简单的替换不就行了。

从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::parsexml(){ 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, (const xmlChar *)"ComConfig"))) { xmlNodePtr comConfigPtr= curNode-》children; while(comConfigPtr!=NULL) { if((!xmlStrcmp(comConfigPtr-》name,(const xmlChar *)"DMS"))) { xmlChar* szAttr = xmlGetProp(comConfigPtr,BAD_CAST "IP"); IP=(char*)szAttr; szAttr=xmlGetProp(comConfigPtr,BAD_CAST "PORT"); PORT=atoi((const char *)szAttr); szAttr=xmlGetProp(comConfigPtr,BAD_CAST "TIMEOUT"); TIMEOUT=atoi((const char *)szAttr); xmlFree(szAttr); } comConfigPtr=comConfigPtr-》next; } }if ((!xmlStrcmp(curNode-》name, (const xmlChar *)"Log"))) { xmlChar* szAttr = xmlGetProp(curNode,BAD_CAST "Flag"); if(szAttr!=NULL) { if((!xmlStrcmp(szAttr,(const 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, (const xmlChar *)"DMS"))) { xmlChar* szAttr = xmlGetProp(curNode,BAD_CAST "Cache"); if(szAttr!=NULL) { Cache=atoi((const char *)szAttr); } xmlFree(szAttr); } if ((!xmlStrcmp(curNode-》name, (const xmlChar *)"SimFile"))) { xmlChar* szAttr = xmlGetProp(curNode,BAD_CAST "Type"); if(szAttr!=NULL) { if((!xmlStrcmp(szAttr,(const xmlChar *)"PlainFilm"))) { xmlNodePtr FileNodes=curNode-》children; int i=0; while(FileNodes!=NULL) { if((!xmlStrcmp(FileNodes-》name,(const 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,(const xmlChar *)"Spiral"))){ xmlNodePtr FileNodes=curNode-》children; int i=0; while(FileNodes!=NULL) { if((!xmlStrcmp(FileNodes-》name,(const 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,(const xmlChar *)"axial"))) { xmlNodePtr FileNodes=curNode-》children; int i=0; while(FileNodes!=NULL) { if((!xmlStrcmp(FileNodes-》name,(const 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文件读不全,望大神解答!!!

把超级列表框换成“高级表格”试试,可能是控件本身的容纳能力吧。没试过那么大的数据。

易语言怎么读入 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》 getPersons(InputStream inputStream) throws Throwable{List《Person》 persons = 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()));}}}persons.add(person);}return persons;}}

易语言怎么修改文件属性和修改XML文件的内容

    open=XXX.exe    icon=XXX.ico只是最常见的,open后面是要运行的文件名,icon后面是盘图标名,还可以加上    shell\open=打开(&O)    shell\open\Command=XXX.exe     替换右键点击盘时的“打开”    shell\open\Default=1    shell\explore=资源管理器(&X)    shell\explore\Command=XXX.exe  替换右键点击盘时的“资源管理器” xxx是你的文件名,比如说替换为a.exe,a.ico,如果你的a.exe里包含图标:    open=a.exe    icon=a.exe,1    shell\open=打开(&O)    shell\open\Command=a.exe    shell\open\Default=1    shell\explore=资源管理器(&X)    shell\explore\Command=a.exe

关于易语言xml解析到此分享完毕,希望能帮助到您。