I am new to VB. How can I customize XML tags in VB?
I need to create XML in the below format using CSV file - I followed the help https://learn.microsoft.com/en-us/dotnet/standard/linq/generate-xml-csv-files.
CSV file example:
Customernumber,name,city,phonenumber
1,xample,delhi,9999999999,****,****
2,test,chennai,9111111111,****,****
--------
-------
XML format required:
<Root>
<Customer1>
<Customer Info>"Info">details</Info>
<Customer Info>"Name">xample</Name>
<Customer Info>"City"> Delhi</Citye>
<Customer Info>"Contact">9999999999</Contact>
</Customer1>
<Customer2>
<Customer Info>"Info">details2</Info>
<Customer Info>"Name">test</Name>
<Customer Info>"City">Chennai</City>
<Customer Info>"Contact">9111111111</Contact>
</Customer2>
similar output but with tag along with number I am not able to print the below tag name along with number and in quotes "info".
<Customer2>
<Customer Info>"info">details</Customer Info>
My code sample:
Dim source As String() = File.ReadAllLines("cust.csv")
Dim cust As XElement = _
<Root>
<%= From strs In source _
Let fields = Split(strs, ",") _
Select _
<Customer>
CustomerNO=<%= fields(0) %>>
<CustomerInfo>
<Customer Info>"ID"><%= fields(0) %></ID>
<Contact Info>"Name"><%= fields(1) %></Name>
<Customer Info>"City"><%= fields(2) %></Place>
<Customer Info>"Contact"><%= fields(3) %></Phone>
</CustomerInfo>
</Customer> _
%>
</Root>
Console.WriteLine(cust)