关于XML element命名问题~
时间:2011-06-22
来源:互联网
大家好,我最近在做一个projet,要写一个XML文件,里面包含了多个conf文件的内容,我的目的就是用expat解析这个XML,然后生成多个conf文件,现在的问题是,我写的XML文件如下:
XML code
我想解析这个XML文件并且生成2个文件分别叫network和wireless, network的内容如下:
XML code
所以我想在element的命名里留空格,但是检查XML form的时候,编写的软件显示,这个element <config interface loopback>有错误,Missing equals sign between attribute and attribute value,请问如何解决这个问题?
PS:如果有哪位高人能再指导下expat的文件怎么写就更加感激不尽了~~
XML code
<?xml version="1.0" encoding="ISO-8859-1"?> <note xmlns="RoxPro" xmlns:xsi="C:/Users/RoxPro/My Documents/" xsi:schemaLocation="RoxPro conf.xsd"> <conf> <network> <config interface loopback> <option> <ifname>lo</ifname> <proto>static</proto> <ipaddr>127.0.0.1</ipaddr> <netmask>255.0.0.0</netmask> </option> </config interface loopback> <config interface lan> <option> <ifname>eth0</ifname> <type>bridge</type> <proto>static</proto> <ipaddr>192.168.1.1</ipaddr> <netmask>255.255.255.0</netmask> </option> </config interface lan> <config interface wifi> <option> <proto>static</proto> <ipaddr>192.168.2.1</ipaddr> <netmask>255.255.255.0</netmask> </option> </config interface wifi> </network> <wireless> <config wifi-device radio0> <option> <type>atheros</type> <channel>auto</channel> <macaddr>00:15:6d:fc:71:ac</macaddr> <disable>0</disable> </option> </config wifi-device radio0> <config wifi-iface> <option> <device>radio0</device> <network>wifi</network> <mode>ap</mode> <ssid>OpenWrt</ssid> <encryption>none</encryption> </option> </config wifi-iface> </wireless> </conf> </note>
我想解析这个XML文件并且生成2个文件分别叫network和wireless, network的内容如下:
XML code
config interface loopback
option ifname lo
option proto static
option ipaddr 127.0.0.1
option netmask 255.0.0.0
config interface lan
option ifname eth0
option type bridge
option proto static
option ipaddr 192.168.1.1
option netmask 255.255.255.0
config interface wifi
option proto static
option ipaddr 192.168.2.1
option netmask 255.255.255.0
所以我想在element的命名里留空格,但是检查XML form的时候,编写的软件显示,这个element <config interface loopback>有错误,Missing equals sign between attribute and attribute value,请问如何解决这个问题?
PS:如果有哪位高人能再指导下expat的文件怎么写就更加感激不尽了~~
作者: RoxPro 发布时间: 2011-06-22
XML 规范规定元素名是不能含有空格的,你含有空格,你的出错提示显示它把 config 视为元素名,interface 视为属性名了.
看你的 XML 结构,其实可以改成 <config interface="loopback">,<config interface="lan">,<config interface="wifi">,使用 xslt 可以很容易转为你想要的文本格式。
看你的 XML 结构,其实可以改成 <config interface="loopback">,<config interface="lan">,<config interface="wifi">,使用 xslt 可以很容易转为你想要的文本格式。
作者: kalala2kalala 发布时间: 2011-06-23
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28