|
|||||||
|
|
|
![]() |
|
|
Strumenti |
|
|
#1 |
|
Senior Member
Iscritto dal: Aug 2000
Messaggi: 1209
|
[C#] Parsing XML da Stringa
Salve, il mio problema è fare il Parsing di un XML che ho in una Stringa,
contenuto della stringa: Codice:
<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE XP SYSTEM "XP.dtd"> <XP> <Start> <Name>MyMame</Name> <Num>321</Num> <Ip>192.168.0.10</Ip> <List> <Param> <Name>Msg</Name> <Value>a</Value> </Param> </List> </Start> </XP> il nodo <Name> su <Start> ed estrarre il suo valore ??? il nodo <Name> su <Param> su <List> ed estrarre il suo valore ??? e per ultimo, come devo fare per generare una stringa come questa ma inserire i Valori che decido io ??? mi potete dare una mano ??? |
|
|
|
|
|
#2 | ||
|
Senior Member
Iscritto dal: Oct 2005
Messaggi: 3306
|
Quote:
Codice:
XMLDocument document = new XMLDocument();
try
{
document.LoadXML(stringaDati);
}
catch(XmlException ex)
{}
XmlNodeList nodeList = document.GetElementsByTagName("Start");
foreach(XMLNode node in nodeList)
{
if (node.Name == "Name")
...
}
Quote:
|
||
|
|
|
|
|
#3 |
|
Senior Member
Iscritto dal: Aug 2000
Messaggi: 1209
|
Ti ringrazio molto, sei stato risolutivo, ho fatto una piccola modifica dato che i nodi sono un numero finito:
Codice:
XmlDocument document = new XmlDocument();
XmlNodeList nodeList = document.GetElementsByTagName("Start");
Console.WriteLine(nodeList[0].InnerXml);
gtrazie ancora... |
|
|
|
|
| Strumenti | |
|
|
Tutti gli orari sono GMT +1. Ora sono le: 18:20.




















