xml获取的节点名字不正确 - VC/MFC / 基础类
需要用到读取xml文件,获取参数。
从网上下载一个xml读取程序,但是他获取的节点的名字不正确,他获取的节点名字都是“#text”:
#include "stdafx.h"
#include <iostream>
using namespace std;
#include <msxml.h>
#include <atlstr.h>
#import "msxml.dll" raw_interfaces_only
int _tmain(int argc, _TCHAR* argv[])
{
::CoInitialize(NULL);
CComPtr<MSXML::IXMLDOMDocument> spDoc;
HRESULT hr = spDoc.CoCreateInstance(__uuidof(MSXML::DOMDocument)); //创建文档对象
VARIANT_BOOL bFlag;
//hr = spDoc->load(CComVariant(L"BitComet.xml"), &bFlag); //load xml文件
hr = spDoc->load(CComVariant(L"simple.xml"), &bFlag); //load xml文件
//hr = spDoc->load(CComVariant(L"example.xml"), &bFlag); //load xml文件
CComPtr<MSXML::IXMLDOMElement> spElement;
hr = spDoc->get_documentElement(&spElement); //获取根结点
CComBSTR strTagName;
hr = spElement->get_tagName(&strTagName);
wcout << "------TagName------" << endl;
wcout <<(LPCTSTR) CString(str
相关问答:
txt 和XML 格式相应
不借助DataSet
导入读取TXT文件
然后直接写入XML(同一文件,不同数据,递增原数据没有被覆盖情况下增加数据.)
教个要点或最好是有个代码提示的
过路好汉 帮个忙撒^^
不会,帮楼主 ......
Private Sub Command1_Click()
Dim MyString() As String
Open "a.xml" For Binary As #1 ' 打开刚创建的文件。
ReDim MyString(LOF(1) - 1)
Put #1, , MyRecord ' 读入所有字符到变量中 ......
下面是XML初始文件内容
XML code:
<upd:Update xmlns:lar="http://schemas.microsoft.com/msus/2002/12/LogicalApplicabilityRules" xmlns:cmd="http://schemas.microsoft.com/msus/2002/12/Up ......
package com.javabean.xml;
import java.net.MalformedURLException;
import java.net.URL;
import org.dom4j.io.SAXReader;
import org.dom4j.Attribute;
import org.dom4j.Document;
import org.dom4j.Docum ......
XML_PARSER_STRUCT parser;
ret = xml_new_parser(&parser);
xml_register_element_handler(&parser, mmi_pict_read_xml_start_element_login, mmi_pict_read_xml_end_element_lo ......