簡體   English   中英

如何閱讀此XML文檔?

[英]how can I read this XML Document?

我對編程還是很陌生,我想閱讀XML文檔。 看起來像下面的示例代碼:

<?xml version="1.0" encoding="utf-8"?>
<Etapa nombre="EnemigosTest" paredH="30" paredV="40">
  <Personaje vida="90" posX="24" posY="10">Cuberin</Personaje>
  <Items>
    <Item tipo="vida" maxApariciones="0" duracion="none" />
    <Item tipo="velocidad" maxApariciones="0" duracion="none" />
  </Items>
  <Plataformas>
    <Plataforma tipo="normal" posX="0" posY="36" ancho="1" duracion="none" />
    <Plataforma tipo="normal" posX="1" posY="36" ancho="1" duracion="none" />
  </Plataformas>
</Etapa>

另外,是否有一種方法可以知道文檔中有多少個節點/屬性/元素?

    XDocument xDocument = XDocument.Load(string URI);
    Debug.WriteLine(xDocument.Elements().Count().ToString()); 

    foreach (XElement xl in xDocument.Elements())
    {
        Debug.WriteLine(xl.Count().ToString());
        foreach (XAttribute xa in xl.Attributes())
        {
            Debug.WriteLine(xa.ToString());
        }
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM