c# – Read the Value out of the XML and parse it to Json
I want to read with xpath my Values and convert it to Json first.
“export”
all results in the json object “data”, plain key-value pairs of the required data.
ResultElement:
type: object
properties:
pdf:
type: string
documenttype:
type: string
data:
type: object
data object
the XML results are to be transferred to the data object.
“meaningful” data types if possible.
ex.:
- “date” for date key
- “double” for currency key
- “string” for everything else
{
“pdf”: “base64 encoded raw pdf”,
“documenttype”: “whatever”,
“data”: {
“Typ”: “Police”,
“Versicherungsnummer”: “123456”
}
}
- NOT * transfer not found or empty data.
<?xml version="1.0" encoding="utf-8"?>
<DOKuStar.Data baseType="documentType" state="Ok" confidence="0" version="4.0">
<annotations>
<annotation key="Name">Allianz_Nachtrag</annotation>
<annotation key="Details">Allianz_Nachtrag</annotation>
<annotation key="InputDirectory">S:ProjekteDEFINETScans Ausweise, Beitragsrechnungen, NachtragPolice-Nachtrag</annotation>
</annotations>
<Unknown baseType="documentType" state="Ok" confidence="100" producer="DOKuStar Extraction">
<sources>
<image guid="286df40b-f372-420c-8a1f-0923c0bce0c1" />
<image guid="7e661f16-1d26-4839-96f5-64463b2c161f" />
<image guid="3270e20e-f138-47a6-b8aa-d6c8b2665bf7" />
<image guid="13831f22-5023-4b3b-8530-d2ff54d6131e" />
<image guid="d5ce3652-8ee7-4098-92d5-9a7ba00105e4" />
<image guid="d6b27484-d097-4bc2-ae98-aa214571d86c" />
</sources>
<Typ baseType="fieldType" state="Ok" confidence="100">
<value>Police</value>
<zone>208 1236 193 46</zone>
<sources>
<image guid="3270e20e-f138-47a6-b8aa-d6c8b2665bf7" />
</sources>
<alternatives>
<Typ baseType="fieldType" state="Ok" confidence="100">
<value>Police</value>
<zone>655 1078 185 31</zone>
<sources>
<image guid="13831f22-5023-4b3b-8530-d2ff54d6131e" />
</sources>
</Typ>
<Typ baseType="fieldType" state="Ok" confidence="100">
<value>Police</value>
<zone>176 500 160 26</zone>
<sources>
<image guid="d5ce3652-8ee7-4098-92d5-9a7ba00105e4" />
</sources>
</Typ>
<Typ baseType="fieldType" state="Ok" confidence="100">
<value>Police</value>
<zone>847 553 104 26</zone>
<sources>
<image guid="d6b27484-d097-4bc2-ae98-aa214571d86c" />
</sources>
</Typ>
</alternatives>
</Typ>
<Versicherungsnummer baseType="fieldType" state="Ok" confidence="97">
<value></value>
<zone>511 921 685 34</zone>
<sources>
<image guid="7e661f16-1d26-4839-96f5-64463b2c161f" />
</sources>
<alternatives>
<Versicherungsnummer baseType="fieldType" state="Ok" confidence="97">
<value>123456</value>
<zone>1002 1236 626 46</zone>
<sources>
<image guid="3270e20e-f138-47a6-b8aa-d6c8b2665bf7" />
</sources>
</Versicherungsnummer>
</alternatives>
</Versicherungsnummer>
</Unknown>
Read more here: Source link