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
  1. Home
  2. General Programming
  3. LINQ
  4. Need help with complicated? XML query

Need help with complicated? XML query

Scheduled Pinned Locked Moved LINQ
csharpdatabaselinqxmlhelp
2 Posts 2 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    YoavBZ
    wrote on last edited by
    #1

    <Hi, I'm new to LINQ and having some problems writing a query that looks at 2 levels of an XML document. This is my XML structure:

    <TransitionList>
    <ActionTransition action="Advance">
    <Transition>
    <OrigStatus>
    <VersionStatus>Added</VersionStatus>
    <PendingDbAction>Add</PendingDbAction>
    <IsDraft>No</IsDraft>
    </OrigStatus>
    <FinalStatus>
    <VersionStatus>Added</VersionStatus>
    <PendingDbAction>None</PendingDbAction>
    <IsDraft>No</IsDraft>
    </FinalStatus>
    </Transition>

    There are many <ActionTransition> with different action attribute, and each contains many <transitions>. I need to find <FinalStatus> by 1. The value of attribute action in the parent '<ActionTransition>'. 2. The value of the 3 values in the '<OrigStatus>' element. I haven't got near to anything that might do this. Is this possible? Thanks.

    M 1 Reply Last reply
    0
    • Y YoavBZ

      <Hi, I'm new to LINQ and having some problems writing a query that looks at 2 levels of an XML document. This is my XML structure:

      <TransitionList>
      <ActionTransition action="Advance">
      <Transition>
      <OrigStatus>
      <VersionStatus>Added</VersionStatus>
      <PendingDbAction>Add</PendingDbAction>
      <IsDraft>No</IsDraft>
      </OrigStatus>
      <FinalStatus>
      <VersionStatus>Added</VersionStatus>
      <PendingDbAction>None</PendingDbAction>
      <IsDraft>No</IsDraft>
      </FinalStatus>
      </Transition>

      There are many <ActionTransition> with different action attribute, and each contains many <transitions>. I need to find <FinalStatus> by 1. The value of attribute action in the parent '<ActionTransition>'. 2. The value of the 3 values in the '<OrigStatus>' element. I haven't got near to anything that might do this. Is this possible? Thanks.

      M Offline
      M Offline
      Michael J Eber
      wrote on last edited by
      #2

      The xml you present is very flat xml. What I'd expect to see is something like this for running a linq query against:

      <Transitions>
      <ActionTransition action="Advance">
      ....
      </ActionTransition>
      <ActionTransition action="Initial">
      ...
      <ActionTransition action="Something">
      </Transitions>

      Your ActionTransition object would then be accessible via it's depths ActionTransition.Transition.FinalStatus.{finalStatusProperty} I'm not 100% certain but I believe you need a recurring entity in your xml to make linq to xml useful.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

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