求助CreateAttribute不能识别命名空间的问题

qicosmos 2009-04-22 09:25:02
<P type="MAC-Address" xsi:type="tP_MAC-Address">01-0C-CD-01-00-03</P>
这是我要写一个结果
pNewNode = pDomDocument->createAttribute(_bstr_t("type"));
pParentNode->attributes->setNamedItem(pNewNode);
pNewNode = pDomDocument->createAttribute(_bstr_t("xsi:type"));
pParentNode->attributes->setNamedItem(pNewNode);

写之后的结果是
<P xsi:type="tP_MAC-Address">01-0C-CD-01-00-03</P>
因为createAttribute时,不识别type前面的命名空间xsi:,认为后面的type和前面的type是同一个,只是更新了type,因此造丢失了一个type,请问该如何解决这个问题,让我在最后能写出后面的type来?
...全文
162 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhiyongtu 2009-05-12
  • 打赏
  • 举报
回复
楼上的办法好像前两天我用过,记得是没有成功,当时把生成的节点加到P节点时发生出错警告。
cds27 2009-05-11
  • 打赏
  • 举报
回复
参考MSXML 4.0 SDK,“createNode”关键字

[C/C++]
C/C++ Syntax
HRESULT createNode(
VARIANT Type,
BSTR name,
BSTR namespaceURI,
IXMLDOMNode **node);
Parameters
Type [in]
The value that uniquely identifies the node type. This can be specified using either the integer value or the string value. For the complete list of values, see the XML DOM Enumerated Constants or the description given for the name parameter.
name [in]
The value for the new node's nodeName property. The relationship between the name and Type parameters is summarized in the Remarks section of this topic.
namespaceURI [in]
The namespace URI. If specified, the node is created in the context of the namespaceURI parameter with the prefix specified on the node name. If the name parameter does not have a prefix, this is treated as the default namespace.
node [out, retval]
The newly created node.
C/C++ Return Values
S_OK
The value returned if successful.
E_INVALIDARG
The value returned if the node parameter is Null.
E_FAIL
The value returned if an error occurs.
zhiyongtu 2009-05-09
  • 打赏
  • 举报
回复
没有找到解决办法,命名冲突真是麻烦!
qicosmos 2009-04-28
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 wisword 的回复:]
node->setAttribute(name,value)
[/Quote]
我用的是VC中MSXML,里面没有这个方法吧。
wisword 2009-04-27
  • 打赏
  • 举报
回复
node->setAttribute(name,value)
cds27 2009-04-27
  • 打赏
  • 举报
回复
你用的是XMLDOM吗?
qicosmos 2009-04-24
  • 打赏
  • 举报
回复
UP,没人知道吗?
qicosmos 2009-04-22
  • 打赏
  • 举报
回复
由于我的积分少不能多给分,还忘多包涵帮忙解答,谢谢了!

8,906

社区成员

发帖
与我相关
我的任务
社区描述
XML/XSL相关问题讨论专区
社区管理员
  • XML/XSL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧