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
相关问答:
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 ......
功能说明:Java servlet 把XML数据压缩后发送到PB用户端,PB收到数据后解压出来.
传输要经过Base64编码.
问题是:能收到数据但是解压不出来.想请教大家或者有什么好的办法?
PB可以用"zlibwapi.DLL" 解压
......
用SAX解析XML中,使用这段代码
String feed="http://www.google.com/ig/api?weather="+strCity;
URL url = new URL(feed.replace(" ", "%20"));
......