【问题标题】:Parsing a XMl with namespaces in C# [duplicate]在 C# 中使用命名空间解析 XML [重复]
【发布时间】:2011-09-07 15:30:09
【问题描述】:

我有这种类型的 XML

<?xml version="1.0" encoding="UTF-8"?>
<ArrayOfCustomer 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns="http://tempuri.org/">

<Customer>
<Customer_id>143</Customer_id>
<Cust_last_name>Deutsch</Cust_last_name>
<Cust_first_name>Leslie</Cust_first_name>
<Gender_id>2</Gender_id>
<Email>ldeutsch16@univ.demo</Email>
<Income_id>3</Income_id>
</Customer>

<Customer>
<Customer_id>327</Customer_id>
<Cust_last_name>Marko</Cust_last_name>
<Cust_first_name>Shelby</Cust_first_name>
<Gender_id>1</Gender_id>
<Email>smarko75@free.demo</Email>
<Income_id>5</Income_id>
</Customer>

</ArrayOfCustomer>

你能建议如何解析它吗?

【问题讨论】:

  • 这段代码有什么问题?
  • 你没有说明你的问题,代码太多了。更简洁。另外,你应该格式化你的代码,这样就可以在不需要水平滚动的情况下阅读它。

标签: c# .net asp.net xml


【解决方案1】:

看起来您正在处理一组客户。尝试使客户可序列化并使用 XML 序列化。您可能还想查看贾斯汀建议的链接。

XML 序列化文档:http://msdn.microsoft.com/en-us/library/182eeyhh(v=VS.100).aspx

【讨论】:

    猜你喜欢
    • 2011-09-20
    • 2012-10-14
    • 1970-01-01
    • 2010-10-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多