I have an XML file,all of it with same elements : <field > </field>
Every field has type "XXX" , and also : <value>AAA</value>
I want to display all the types and values in console mode
Examples :
type : MrzType type: DocumentType ....
Value : 2line Value: P
I have this code:
XmlDocument Xmldoc = new XmlDocument();
Xmldoc.Load(@"C:\image.xml");
foreach (XmlElement element in Xmldoc.GetElementsByTagName("field"))
{
if (element.HasAttribute("type"))
{
Console.WriteLine("type : " + element.GetAttribute("type"));
}
Console.WriteLine("Value : " + element.InnerText);
Console.ReadLine();
}
But i have just the result:
type : MrzType Value : 2line
I want to display all types and their values?
This is my file XML ,image.xml:
<document>
<field type="MrzType">
<value>2line</value>
</field>
<field type="DocumentNumber">
<value>R420604</value>
</field>
<field type="DocumentType">
<value>P</value>
</field>
<field type="DocumentSubtype">
<value><</value>
</field>
<field type="IssuingCountry">
<value>TUN</value>
</field>
<field type="LastName">
<value>THABET</value>
</field>
Thanks,
cut the Console.ReadLine();
line and paste it after }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.