EDN Admin
Well-known member
Hi to all,<br/>
<br/>
Im tying to populate a dictionary taking contents and values form XML element document.<br/>
<br/>
Ive deploy one function:<br/>
<br/>
addToDictionary(DICT, reader.LocalName, reader.ReadString)<br/>
<br/>
This function adds to DICT dictionary, a key: reader.LocalName with value reader.ReadString<br/>
<br/>
After that Ive compose following code for parse the entire XML and adds all elements to dictionary. The code works, but Ive found that some element its not added to dictionary.<br/>
<br/>
In particular the element that its not added are the first of every child node encountered example ( name , street )<br/>
<br/>
Iâd kindly ask if you someone can propose a solution, below Ive attach code and XML document.<br/>
<br/>
Thank you very much for your help!<br/>
<br/>
Regards<br/>
Maurizio<br/>
<br/>
==== START CODE ====<br/>
<br/>
Dim xmlDocument As New Xml.XmlDocument()<br/>
xmlDocument.LoadXml(myOBJECT.OuterXml)<br/>
<br/>
Dim reader As System.Xml.XmlReader = System.Xml.XmlReader.Create(New System.IO.StringReader(EPPDataInResData.OuterXml))<br/>
While reader.Read()<br/>
If reader.MoveToContent() = XmlNodeType.Element Then<br/>
addToDictionary(DICT, reader.LocalName, reader.ReadString)<br/>
End If<br/>
End While<br/>
<br/>
==== END CODE ====<br/>
<br/>
==== START XML ====<br/>
<br/>
<contact:infData xmlns:contact="urn:ietfarams:xml:ns:contact-1.0" xsi:schemaLocation="urn:ietfarams:xml:ns:contact-1.0 contact-1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance <br/>
<br/>
<contact:id>AAA</contact:id> <br/>
<contact:roid>BBB</contact:roid> <br/>
<contact:status s="ok" lang="en" /> <br/>
<contact:status s="linked" lang="en" /> <br/>
<br/>
<contactostalInfo type="loc <br/>
<br/>
<contact:name>CCC</contact:name> <br/>
<contactrg>DDD</contactrg> <br/>
<br/>
<contact:addr><br/>
<contact:street>EEE</contact:street> <br/>
<contact:city>FFF</contact:city> <br/>
<contact:sp>GGG</contact:sp> <br/>
<contactc>HHH</contactc> <br/>
<contact:cc>III</contact:cc> <br/>
</contact:addr><br/>
<br/>
</contactostalInfo><br/>
<br/>
<contact:voice x=" LLL</contact:voice> <br/>
<contact:fax x=" MMM</contact:fax> <br/>
<contact:email>NNN</contact:email> <br/>
<contact:clID>OOO</contact:clID> <br/>
<contact:crID>PPP</contact:crID> <br/>
<contact:crDate>QQQ</contact:crDate> <br/>
<contact:upID>RRR</contact:upID> <br/>
<contact:upDate>SSS</contact:upDate> <br/>
<br/>
</contact:infData><br/>
<br/>
==== END XML ====
View the full article
<br/>
Im tying to populate a dictionary taking contents and values form XML element document.<br/>
<br/>
Ive deploy one function:<br/>
<br/>
addToDictionary(DICT, reader.LocalName, reader.ReadString)<br/>
<br/>
This function adds to DICT dictionary, a key: reader.LocalName with value reader.ReadString<br/>
<br/>
After that Ive compose following code for parse the entire XML and adds all elements to dictionary. The code works, but Ive found that some element its not added to dictionary.<br/>
<br/>
In particular the element that its not added are the first of every child node encountered example ( name , street )<br/>
<br/>
Iâd kindly ask if you someone can propose a solution, below Ive attach code and XML document.<br/>
<br/>
Thank you very much for your help!<br/>
<br/>
Regards<br/>
Maurizio<br/>
<br/>
==== START CODE ====<br/>
<br/>
Dim xmlDocument As New Xml.XmlDocument()<br/>
xmlDocument.LoadXml(myOBJECT.OuterXml)<br/>
<br/>
Dim reader As System.Xml.XmlReader = System.Xml.XmlReader.Create(New System.IO.StringReader(EPPDataInResData.OuterXml))<br/>
While reader.Read()<br/>
If reader.MoveToContent() = XmlNodeType.Element Then<br/>
addToDictionary(DICT, reader.LocalName, reader.ReadString)<br/>
End If<br/>
End While<br/>
<br/>
==== END CODE ====<br/>
<br/>
==== START XML ====<br/>
<br/>
<contact:infData xmlns:contact="urn:ietfarams:xml:ns:contact-1.0" xsi:schemaLocation="urn:ietfarams:xml:ns:contact-1.0 contact-1.0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance <br/>
<br/>
<contact:id>AAA</contact:id> <br/>
<contact:roid>BBB</contact:roid> <br/>
<contact:status s="ok" lang="en" /> <br/>
<contact:status s="linked" lang="en" /> <br/>
<br/>
<contactostalInfo type="loc <br/>
<br/>
<contact:name>CCC</contact:name> <br/>
<contactrg>DDD</contactrg> <br/>
<br/>
<contact:addr><br/>
<contact:street>EEE</contact:street> <br/>
<contact:city>FFF</contact:city> <br/>
<contact:sp>GGG</contact:sp> <br/>
<contactc>HHH</contactc> <br/>
<contact:cc>III</contact:cc> <br/>
</contact:addr><br/>
<br/>
</contactostalInfo><br/>
<br/>
<contact:voice x=" LLL</contact:voice> <br/>
<contact:fax x=" MMM</contact:fax> <br/>
<contact:email>NNN</contact:email> <br/>
<contact:clID>OOO</contact:clID> <br/>
<contact:crID>PPP</contact:crID> <br/>
<contact:crDate>QQQ</contact:crDate> <br/>
<contact:upID>RRR</contact:upID> <br/>
<contact:upDate>SSS</contact:upDate> <br/>
<br/>
</contact:infData><br/>
<br/>
==== END XML ====
View the full article