Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
B

Ben Senior

@Ben Senior
About
Posts
6
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Retrieving value from an XML file
    B Ben Senior

    Thanks for that Meschack, As I said above I have solved that problem, with the help of people here, and now moved on to the next stage in the project, which is moving along quite well. I have noted your suggestions along with the others, for reference and future use.

    Visual Basic csharp xml help

  • Retrieving value from an XML file
    B Ben Senior

    I had to add the root to the code ie. "/mtf/conceptGrp/descripGrp/descrip[@type='subjectField']" and a variable codeID to hold the value from

    codeID = xNode.InnerText

    instead of your

    xNode.InnerText

    I replaced the codeID with codeText (the corresponding text from my function) and reinserted it into the xml file. I need to test out the subjectField, but I don't anticipate any difficulties because it basically the same as for reliabilityCode. Works a treat. Thanks for your help. Now I'm getting there with XPath :)

    Visual Basic csharp xml help

  • Retrieving value from an XML file
    B Ben Senior

    That is correct. There is in each element just one 6411, 6821. There are over 700 possible values for subjectField and there can be multiple values each separated by a comma. Her we have two values "6411" and "6821". In each element there are a minimum of two languageGrp and a maximum of thirty. It varies throughout the file. In each languageGrp there is at least one termGrp up to a maximum of 10. In each termGrp there is just one 3. There are up to five possible values of this code, here it is "3". I've never used XPath and have not much useful reference material at the moment. It's all new to me, I'm an old VB/C# horse.

    Visual Basic csharp xml help

  • Retrieving value from an XML file
    B Ben Senior

    Hi David, No. What I want to do is take: 3 and replace it with: Very reliable The "3" can vary and when I get this numerical code I have a function from where I can retrieve its text equivalent. I then need to insert the text equivalent back into the XML file. There are five of these numeric codes. I'm new to XML and have never used XPath before so I'm struggling at the moment. I've been researching XPath and LINQ and just can't seem to get the hang of them. I have been using the looping as that's what I'm used to doing in VB and C#. The last thing that I will need to do is go through each element and depending upon the value of the subject field write the whole element to a new file for that subject. But first thing first and replace the numeric codes with text. The subjectField is very similar other than there are over 700 subjects. I already have a function which converts the numeric subject field codes into text, and as above I need to insert the text back into the XML file.

    Visual Basic csharp xml help

  • Retrieving value from an XML file
    B Ben Senior

    Not at all a helpful answer, but thanks for taking the time to write something :-(

    Visual Basic csharp xml help

  • Retrieving value from an XML file
    B Ben Senior

    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:

    -<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>:

    ' 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")

    Visual Basic csharp xml help
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups