【问题标题】:Write soap XML using XOM使用 XOM 编写肥皂 XML
【发布时间】:2011-10-07 13:54:25
【问题描述】:

我正在尝试使用以下内容编写肥皂消息:

<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"  
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">

使用XOM

我正在使用

创建元素
Element soap = new Element("soap:Envelope", "http://schemas.xmlsoap.org/soap/envelope/");

但我不知道如何添加 xmlns:xsi 和 xmln:xsd 属性。使用

Attribute xsi = new Attribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");

返回以下错误

Attribute objects are not used to represent namespace declarations

那么如何添加这些属性呢?

谢谢

【问题讨论】:

  • 你必须使用 XOM 吗?你能自己把soap/xml写出来然后发送吗?
  • 是的,这就是我要做的......

标签: android xml xom


【解决方案1】:

XOM 和其他基于树的包应该自动添加所需的命名空间声明, 基于您为元素和属性定义的命名空间 URI(可能还有前缀)。 那么你为什么要明确地添加它们呢?不行吗?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-08
    • 2017-11-09
    相关资源
    最近更新 更多