账号密码登录
微信安全登录
微信扫描二维码登录

登录后绑定QQ、微信即可实现信息互通

手机验证码登录
找回密码返回
邮箱找回 手机找回
注册账号返回
其他登录方式
分享
  • 收藏
    X
    golang xml 解析数组
    63
    0
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <response>
        <flag>success</flag>
        <code>SUCCESS</code>
        <message>查询成功!</message>
        <items>
            <item>
                <warehouseCode>B01</warehouseCode>
                <itemCode>123</itemCode>
                <itemId>123</itemId>
                <inventoryType>CC</inventoryType>
                <quantity>3</quantity>
                <lockQuantity>0</lockQuantity>
            </item>
            <item>
                <warehouseCode>B01</warehouseCode>
                <itemCode>333</itemCode>
                <itemId>555</itemId>
                <inventoryType>ZP</inventoryType>
                <quantity>5239</quantity>
                <lockQuantity>0</lockQuantity>
            </item>
        </items>
    </response>

    对应的 struct

    Response struct {
        XMLName xml.Name `xml:"response"`
        Flag    string   `xml:"flag"`
        Code    string   `xml:"code"`
        Message string   `xml:"message"`
        Items   []Item   `xml:"items"`
    }
    
    Item struct {
        WarehouseCode string `xml:"warehouseCode"`
        ItemCode      string `xml:"itemCode"`
        ItemID        string `xml:"itemId"`
        InventoryType string `xml:"inventoryType"`
        Quantity      string `xml:"quantity"`
        LockQuantity  string `xml:"lockQuantity"`
    }
    
    
    

    结果打印出来 xml Response Items : [{ }]

    Items 竟然是 空 请求大佬 这样的 xml 不是这么定义的吗?

    找个大佬 指导一下咯 ?

    0
    打赏
    收藏
    点击回答
        全部回答
    • 0
    • 叶筱引 普通会员 1楼
      502 Bad Gateway

      502 Bad Gateway


      nginx
    更多回答
    扫一扫访问手机版
    • 回到顶部
    • 回到顶部