3XLcom
asked on
Read XML .Net
I want to read values from an xml as this :
XXXXXXXXXXXXXXXX
PPPPPPPPPPPPPPPPPPPP
MMMMMMMMMMMMM
NNNNNNNNNNNNNNNNNN
YYYYYYYYYYYYYY
ZZZZZZZZZZZZZZZZZ
values
XXXXXXXXXXXXXXXX
PPPPPPPPPPPPPPPPPPPP
MMMMMMMMMMMMM
NNNNNNNNNNNNNNNNNN
YYYYYYYYYYYYYY
ZZZZZZZZZZZZZZZZZ
values
<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing">
<soapenv:Header>
<wsa:Address>
http://www.w3.org/2005/08/addressing/none
</wsa:Address>
></wsa:ReplyTo></soapenv:Header><soapenv:Body>
<EnergyAccountReport DtdRelease="1" DtdVersion="1">
<DocumentIdentification v="ZZZZZZZZZZZZZZZZZZZZZ" />
<DocumentVersion v="1" />
<DocumentType v="A11" />
<DocumentStatus v="A02" />
<ProcessType v="A05" />
<ClassificationType v="A01" />
<SenderIdentification codingScheme="A01" v="NNNNNNNNNNNNNNNNN" />
<SenderRole v="A09" />
<ReceiverIdentification codingScheme="A01" v="MMMMMMMMMMMMMMMMM" />
<ReceiverRole v="A05" />
<DocumentDateTime v="2010-09-21T12:39Z" />
<AccountingPeriod v="2010-08-10T00:00Z/2010-08-10T23:59Z" />
<Domain codingScheme="A01" v="PPPPPPPPPPPPPPPPPPPPP" />
<AccountTimeSeries>
<SendersTimeSeriesIdentification v="00000000000000000000000000000000001" />
<BusinessType v="A14" />
<Product v="8716867000030" />
<ObjectAggregation v="A02" />
<Area codingScheme="A01" v="10YTR-1001A0006O" />
<Party xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" /><AgreementIdentification xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" /><MeasurementUnit v="MWH" /><Currency v="TRY" /><AccountingPoint codingScheme="A01" v="XXXXXXXXXXXXX" /><Period>
<TimeInterval v="2010-08-10T00:00Z/2010-08-10T23:59Z" /><Resolution v="PT1H" /><AccountInterval>
<Pos v="1" /><InQty v="0.0" /><OutQty v="YYYYYYYYYYY" /><SettlementAmount v="0.0" /></AccountInterval><AccountInterval>
<Pos v="2" /><InQty v="0.0" /><OutQty v="YYYYYYYYYYY" /><SettlementAmount v="0.0" /></AccountInterval><AccountInterval>
...........
<Party xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" /><AgreementIdentification xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" /><MeasurementUnit v="MWH" /><Currency v="TRY" /><AccountingPoint codingScheme="A01" v="XXXXXXXXXXXXXXXXX" /><Period>
<TimeInterval v="2010-08-10T00:00Z/2010-08-10T23:59Z" /><Resolution v="PT1H" /><AccountInterval>
<Pos v="1" /><InQty v="0.0" /><OutQty v="YYYYYYYYYYYYY" /><SettlementAmount v="0.0" /></AccountInterval><AccountInterval>
<Pos v="2" /><InQty v="0.0" /><OutQty v="YYYYYYYYYYYYY" /><SettlementAmount v="0.0" /></AccountInterval><AccountInterval>
................
ASKER
real xml file is tooooo long
:(
unfortunately so could you send me the code so i could test it
:(
unfortunately so could you send me the code so i could test it
You can add the xml-file into the question, you don't have to copy and paste it...
Without correct xml it's very hard to give you a good programming solution.
Did you try the dataset readxml ?
Without correct xml it's very hard to give you a good programming solution.
Did you try the dataset readxml ?
ASKER
unfortunatelly there are some important values in it so i need to try on this side for to check if it is work :( but if you help me i will be very glad for this
this is the main part of xml so you could also complete this part of xml to test
this is the main part of xml so you could also complete this part of xml to test
Can you tell me the structure than, before I test further. Is this part repeating (for different party's ?) Something like below ?
<Party xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" /><AgreementIdentification xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" /><MeasurementUnit v="MWH" /><Currency v="TRY" /><AccountingPoint codingScheme="A01" v="XXXXXXXXXXXXX" /><Period>
<TimeInterval v="2010-08-10T00:00Z/2010- 08-10T23:5 9Z" /><Resolution v="PT1H" /><AccountInterval>
<Pos v="1" /><InQty v="0.0" /><OutQty v="YYYYYYYYYYY" /><SettlementAmount v="0.0" /></AccountInterval><Accou ntInterval >
<Pos v="2" /><InQty v="0.0" /><OutQty v="YYYYYYYYYYY" /><SettlementAmount v="0.0" /></AccountInterval><Accou ntInterval >
<Party xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" /><AgreementIdentification
<TimeInterval v="2010-08-10T00:00Z/2010-
<Pos v="1" /><InQty v="0.0" /><OutQty v="YYYYYYYYYYY" /><SettlementAmount v="0.0" /></AccountInterval><Accou
<Pos v="2" /><InQty v="0.0" /><OutQty v="YYYYYYYYYYY" /><SettlementAmount v="0.0" /></AccountInterval><Accou
<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsa="http://www.w3.org/2005/08/addressing">
<soapenv:Header>
<wsa:Address>
http://www.w3.org/2005/08/addressing/none
</wsa:Address>
</soapenv:Header>
<soapenv:Body>
<EnergyAccountReport DtdRelease="1" DtdVersion="1">
<DocumentIdentification v="ZZZZZZZZZZZZZZZZZZZZZ" />
<DocumentVersion v="1" />
<DocumentType v="A11" />
<DocumentStatus v="A02" />
<ProcessType v="A05" />
<ClassificationType v="A01" />
<SenderIdentification codingScheme="A01" v="NNNNNNNNNNNNNNNNN" />
<SenderRole v="A09" />
<ReceiverIdentification codingScheme="A01" v="MMMMMMMMMMMMMMMMM" />
<ReceiverRole v="A05" />
<DocumentDateTime v="2010-09-21T12:39Z" />
<AccountingPeriod v="2010-08-10T00:00Z/2010-08-10T23:59Z" />
<Domain codingScheme="A01" v="PPPPPPPPPPPPPPPPPPPPP" />
<AccountTimeSeries>
<SendersTimeSeriesIdentification v="00000000000000000000000000000000001" />
<BusinessType v="A14" />
<Product v="8716867000030" />
<ObjectAggregation v="A02" />
<Area codingScheme="A01" v="10YTR-1001A0006O" />
</AccountTimeSeries>
<partys>
<partyOne>
<Party xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
<AgreementIdentification xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
<MeasurementUnit v="MWH" />
<Currency v="TRY" />
<AccountingPoint codingScheme="A01" v="XXXXXXXXXXXXX" />
<Period>
<TimeInterval v="2010-08-10T00:00Z/2010-08-10T23:59Z" />
<Resolution v="PT1H" />
<AccountInterval>
<Pos v="1" />
<InQty v="0.0" />
<OutQty v="YYYYYYYYYYY" />
<SettlementAmount v="0.0" />
</AccountInterval>
<AccountInterval>
<Pos v="2" />
<InQty v="0.0" />
<OutQty v="YYYYYYYYYYY" />
<SettlementAmount v="0.0" />
</AccountInterval>
</Period>
</partyOne>
<partyOne>
<Party xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
<AgreementIdentification xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
<MeasurementUnit v="MWH" />
<Currency v="TRY" />
<AccountingPoint codingScheme="A01" v="XXXXXXXXXXXXX" />
<Period>
<TimeInterval v="2010-08-10T00:00Z/2010-08-10T23:59Z" />
<Resolution v="PT1H" />
<AccountInterval>
<Pos v="1" />
<InQty v="0.0" />
<OutQty v="YYYYYYYYYYY" />
<SettlementAmount v="0.0" />
</AccountInterval>
<AccountInterval>
<Pos v="2" />
<InQty v="0.0" />
<OutQty v="YYYYYYYYYYY" />
<SettlementAmount v="0.0" />
</AccountInterval>
</Period>
</partyOne>
</partys>
</EnergyAccountReport>
</soapenv:Body>
</soapenv:Envelope>
ASKER
exactly yes
Tell me exactly what you need. I assume also that you want these items for each party ?
For example:
XXXXXXXXXXXXXXXX --> xml-tag:
PPPPPPPPPPPPPPPPPPPP
MMMMMMMMMMMMM --> xml-tag: ReceiverIdentification , attribute v
NNNNNNNNNNNNNNNNNN --> xml-tag: SenderIdentification , attribute v
YYYYYYYYYYYYYY
ZZZZZZZZZZZZZZZZZ
For example:
XXXXXXXXXXXXXXXX --> xml-tag:
PPPPPPPPPPPPPPPPPPPP
MMMMMMMMMMMMM --> xml-tag: ReceiverIdentification , attribute v
NNNNNNNNNNNNNNNNNN --> xml-tag: SenderIdentification , attribute v
YYYYYYYYYYYYYY
ZZZZZZZZZZZZZZZZZ
ASKER
yes
ASKER
that is what totaly i need as you write this parts of xml
>> that is what totaly i need as you write this parts of xml
So you don't have figured out what mapping you need ? Which field of the xml you need ?
So you don't have figured out what mapping you need ? Which field of the xml you need ?
ASKER
sir this xxxxx yyyy zzzzz in reality has some values i need to read them that is all
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>> sir this xxxxx yyyy zzzzz in reality has some values i need to read them that is all
I agree, but where exactly in the xml are the coming from ? From the fields I guessed above in the code ?
I agree, but where exactly in the xml are the coming from ? From the fields I guessed above in the code ?
ASKER
that code giving error :
For Each xParty As XmlElement In doc.Descendants("Party")
For Each xParty As XmlElement In doc.Descendants("Party")
ASKER
because of this :
Descendants
Descendants
That's possible... Probably the layout of the xml is not completly the same as I used !
So I had to guess how the xml is structured (and I used it like this:
<soapenv:Body>
<EnergyAccountReport>
<Partys>
<PartyOne>
<Party> .... </Party>
<Party> .... </Party>
</PartyOne>
</Partys>
</EnergyAccountReport>
</soapenv:Body>
So I had to guess how the xml is structured (and I used it like this:
<soapenv:Body>
<EnergyAccountReport>
<Partys>
<PartyOne>
<Party> .... </Party>
<Party> .... </Party>
</PartyOne>
</Partys>
</EnergyAccountReport>
</soapenv:Body>
ASKER
no no .net does not accept the word :
Descendants
Descendants
What version of .net are you using ? I used 3.5 (with LINQ)
ASKER
vs2010 :D but could not find linq on the reference list let me check it on .net 4 framework
ASKER
Worked perfectly thanks
1. Read the entire xml in a dataset, and use the right table, columns to get your data
2. Use xpath-querys
Can you give your complete xml-file, so that I can test both ways. Also tell me exactly what you need.
For example:
XXXXXXXXXXXXXXXX --> xml-tag:
PPPPPPPPPPPPPPPPPPPP
MMMMMMMMMMMMM --> xml-tag: ReceiverIdentification , attribute v
NNNNNNNNNNNNNNNNNN --> xml-tag: SenderIdentification , attribute v
YYYYYYYYYYYYYY
ZZZZZZZZZZZZZZZZZ
Open in new window