Results 1 to 3 of 3

Thread: xdocument to xmldocument query

  1. #1

    Thread Starter
    Fanatic Member staticbob's Avatar
    Join Date
    Jan 2005
    Location
    Manchestershire, UK Cabbage: I do
    Posts
    619

    xdocument to xmldocument query

    Guys,

    Can somebody help me take this from an xdocument linQ query syntax to something that will work in .net 3.0 please...

    Thanks
    Bob

    Code:
                '####### 3.5 ########
                Dim document As XDocument = XDocument.Load(Session("str_XMLDataFile"))
                Dim sectionName As String = XPathBinder.Eval(DataBinder.GetDataItem(e.AccordionItem), "@SectionName").ToString()
    
                Dim questions = From question In document.Descendants("Question") _
                                Where question.Parent.Attribute("SectionName").Value = sectionName _
                                Select Text = question.Element("Text").Value, _
                                    Comment = question.Element("Comment").Value, _
                                    VDSCode = question.Element("VDSCode").Value, _
                                    Category = question.Element("Category").Value, _
                                    YesNo = question.Element("YesNo").Value
    
                Dim lstQuestions As Repeater = TryCast(e.AccordionItem.FindControl("lstQuestions"), Repeater)
                lstQuestions.DataSource = questions
                lstQuestions.DataBind()

    Example of XML Data...

    Code:
     <?xml version="1.0" encoding="utf-8" ?> 
    - <PPRObject>
    - <Section SectionName="Major Part Assessment">
    - <Question>
      <Text>Datum, Secondary, Clearance Fixings</Text> 
      <DocumentLink>D:\Bentley\embededdocumentrequirements.doc</DocumentLink> 
      <Comment /> 
      <Category /> 
      <VDSCode /> 
      <YesNo /> 
      </Question>
    - <Question>
      <Text>Assistor required?</Text> 
      <DocumentLink>www.google.com</DocumentLink> 
      <Comment /> 
      <Category /> 
      <VDSCode /> 
      <YesNo /> 
      </Question>
    - <Question>
      <Text>Protection / Damage potential</Text> 
      <DocumentLink /> 
      <Comment /> 
      <Category /> 
      <VDSCode /> 
      <YesNo /> 
      </Question>
    - <Question>
    "I dislike 7 am. If 7 am were a person, I would punch 7 am in the biscuits." - Paul Ryan, DailyRamblings

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: xdocument to xmldocument query

    Is this a crosspost? I vaguely recall answering something similar by you in another thread.

  3. #3

    Thread Starter
    Fanatic Member staticbob's Avatar
    Join Date
    Jan 2005
    Location
    Manchestershire, UK Cabbage: I do
    Posts
    619

    Re: xdocument to xmldocument query

    Yup. Delete if you have the POWERRRRRRRRR
    "I dislike 7 am. If 7 am were a person, I would punch 7 am in the biscuits." - Paul Ryan, DailyRamblings

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width