Post by FabrizioPost by Andrea (Work)Ad ogni modo dall'xsd a crearsi le classi è un attimo. A quel punto io
parto da un template XML con i dati identificativi del cliente (estratto
dal sample del sito)
Andrea ... senza volere aprofittare ...
Sto provando a guardare l'argomento XML che finora non ho mai incrociato
Mi potresti dire due parole a chiarimento di questa tua affermazione
quotata sopra in modo da partire nella giusta direzione?
Grazie anticipatamente
Certo nessun problema.
In una cartella config creo un file tipo questo come template.xml:
https://pastebin.com/jXwT3Bim
Poi la creazione parto da quel template:
| Dim config As FatturaElettronicaType
|
| Dim cfgFilePath As String = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
| "config\template.xml")
|
| ' leggo un file xml template If File.Exists(cfgFilePath) Then Dim ser As
| New XmlSerializer(GetType(FatturaElettronicaType), GetRoot(True)) config
| = DirectCast(ser.Deserialize(New StreamReader(cfgFilePath, New
| System.Text.UTF8Encoding)), FatturaElettronicaType)
|
| Try WriteXML(config, idFattura) Catch ex As Exception
| MessageBox.Show(ex.Message, "Errore") End Try End If
In WriteXML popolo tutti i campi che voglio leggendo dalla fattura
specificata.
es.
| Dim np As FatturaElettronicaType = template
| With np.FatturaElettronicaHeader.DatiTrasmissione
| .CodiceDestinatario = row("CODDESTINATARIOPA").ToString
| .ProgressivoInvio = row("PROGRINVIO").ToString
| .FormatoTrasmissione = FormatoTrasmissioneType.FPA12
| End With
|
| Dim cessionarioCommittente As New CessionarioCommittenteType()
| Dim datiAnagraficiCommittente As New DatiAnagraficiCessionarioType()
| datiAnagraficiCommittente.CodiceFiscale = row("CODFISC").ToString
E alla fine serializzo l'xml (manca qualche funzione GetRoot setta degli
attributi sull'xml)
| Dim ser As New XmlSerializer(np.[GetType](), GetRoot)
| Dim file As System.IO.FileStream = System.IO.File.Create(saveFileName)
| ser.Serialize(New StreamWriter(file, New System.Text.UTF8Encoding()), np, ns)
|
| file.Close()