Click here to Skip to main content
15,793,452 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Yahoo Finance API Throwing 504 Status? Pin
Afzaal Ahmad Zeeshan20-May-17 0:56
professionalAfzaal Ahmad Zeeshan20-May-17 0:56 
QuestionOutlook signature code suddenly causing "remote procedure call failed" message Pin
Member 1320910118-May-17 8:18
Member 1320910118-May-17 8:18 
AnswerRe: Outlook signature code suddenly causing "remote procedure call failed" message Pin
Richard MacCutchan18-May-17 22:43
mveRichard MacCutchan18-May-17 22:43 
GeneralRe: Outlook signature code suddenly causing "remote procedure call failed" message Pin
Member 134178014-Dec-19 4:07
Member 134178014-Dec-19 4:07 
GeneralRe: Outlook signature code suddenly causing "remote procedure call failed" message Pin
Richard MacCutchan4-Dec-19 4:28
mveRichard MacCutchan4-Dec-19 4:28 
GeneralRe: Outlook signature code suddenly causing "remote procedure call failed" message Pin
Member 134178014-Dec-19 4:32
Member 134178014-Dec-19 4:32 
GeneralRe: Outlook signature code suddenly causing "remote procedure call failed" message Pin
Richard MacCutchan4-Dec-19 4:45
mveRichard MacCutchan4-Dec-19 4:45 
QuestionRetrieving value from an XML file Pin
Ben Senior17-May-17 9:32
Ben Senior17-May-17 9:32 
I'm new to working with XML in VB.NET and would like a little help after tearing my hair out for a couple of days.

I have an XML file with the following structure:

XML
-<conceptGrp>
  -<descripGrp>
    <descrip type="subjectField">6411, 6821</descrip>
   </descripGrp>
  -<languageGrp>
    <language lang="DE" type="German"/>
   -<termGrp>
      <term>Scheren</term>
     -<descripGrp>
        <descrip type="termType">fullForm</descrip>
      </descripGrp>
     -<descripGrp>
        <descrip type="reliabilityCode">3</descrip>
      </descripGrp>
    </termGrp>
   </languageGrp>
  -<languageGrp>
    <language lang="EN" type="English"/>
   -<termGrp>
      <term>scissors</term>
     -<descripGrp>
        <descrip type="termType">fullForm</descrip>
      </descripGrp>
     -<descripGrp>
        <descrip type="reliabilityCode">3</descrip>
      </descripGrp>
    </termGrp>
   </languageGrp>
</conceptGrp>


First I need to cycle through all the elements in the file (>550000) and for each element extract the text
"6411, 6821" from
<descrip type="subjectField">6411, 6821</descrip>

and
"3" from
<descrip type="reliabilityCode">3</descrip>


The <descrpGrp> appears just once for each element.
The <languageGrp> appears at least twice but up to 20 times.
The <termGrp> appears mostly once but up to 10 times for each <languageGrp>.
The <descrpGrp> appears twice for each <termGrp>.
The <descrip type="reliabilityCode" ...> appears just once for each term.

Using the extracted strings I look them up and need to replace them with text in the element.

This is my code so far for getting the <descrip type="reliabilityCode">3</descrip>:

VB
' loop thro each element in XML doc and replace the reliabiltiy codes
        For Each conceptGrp In xDoc.Elements("conceptGrp")
            For Each languageGrp In conceptGrp.Elements("languageGrp")
                For Each termGrp In languageGrp.Elements("termGrp")
                    Dim code = termGrp.Element("reliabilityCode")
                    For Each descripGP In termGrp.Elements("descripGrp")
                        For Each descrip In descripGP.Elements("descrip")
                            Dim reliability As String = xDoc.selectSingleNode("/Categories/category[@descrip='reliability code']").InnerText

                        Next descrip
                    Next descripGP
                Next termGrp
            Next languageGrp
        Next conceptGrp


When I look in the locals window I can see "descrip" and for the first node the property "next node" with the value I want but I just can't grab it.

How can I easily get the value and then replace it in the element with my looked up text?

Thanks
Ben

modified 17-May-17 20:17pm.

GeneralRe: Retrieving value from an XML file Pin
PIEBALDconsult17-May-17 15:11
professionalPIEBALDconsult17-May-17 15:11 
GeneralRe: Retrieving value from an XML file Pin
Ben Senior17-May-17 23:33
Ben Senior17-May-17 23:33 
GeneralRe: Retrieving value from an XML file Pin
Richard MacCutchan18-May-17 0:08
mveRichard MacCutchan18-May-17 0:08 
GeneralRe: Retrieving value from an XML file Pin
Ben Senior19-May-17 8:40
Ben Senior19-May-17 8:40 
GeneralRe: Retrieving value from an XML file Pin
Richard MacCutchan19-May-17 22:13
mveRichard MacCutchan19-May-17 22:13 
AnswerRe: Retrieving value from an XML file Pin
David Mujica19-May-17 8:02
David Mujica19-May-17 8:02 
GeneralRe: Retrieving value from an XML file Pin
Ben Senior19-May-17 8:26
Ben Senior19-May-17 8:26 
GeneralRe: Retrieving value from an XML file Pin
David Mujica19-May-17 9:28
David Mujica19-May-17 9:28 
AnswerRe: Retrieving value from an XML file Pin
Ben Senior20-May-17 5:28
Ben Senior20-May-17 5:28 
AnswerRe: Retrieving value from an XML file Pin
Meshack Musundi23-May-17 6:58
professionalMeshack Musundi23-May-17 6:58 
GeneralRe: Retrieving value from an XML file Pin
Ben Senior23-May-17 8:33
Ben Senior23-May-17 8:33 
QuestionCatching Control, Shift Key and Alt Key Presses and Releases Pin
Jalapeno Bob16-May-17 12:19
professionalJalapeno Bob16-May-17 12:19 
AnswerRe: Catching Control, Shift Key and Alt Key Presses and Releases Pin
Alex k (oShortyo)17-May-17 0:16
Alex k (oShortyo)17-May-17 0:16 
AnswerRe: Catching Control, Shift Key and Alt Key Presses and Releases Pin
Richard Deeming17-May-17 2:19
mveRichard Deeming17-May-17 2:19 
GeneralRe: Catching Control, Shift Key and Alt Key Presses and Releases Pin
Jalapeno Bob17-May-17 8:03
professionalJalapeno Bob17-May-17 8:03 
QuestionGET PC POSITION IN VISUAL BASIC Pin
Otekpo Emmanuel9-May-17 14:28
Otekpo Emmanuel9-May-17 14:28 
AnswerRe: GET PC POSITION IN VISUAL BASIC Pin
Chris Quinn9-May-17 22:28
Chris Quinn9-May-17 22:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.