Click here to Skip to main content
15,906,463 members
Home / Discussions / C#
   

C#

 
AnswerRe: .net Query Pin
Keith Barrow7-Aug-14 1:45
professionalKeith Barrow7-Aug-14 1:45 
AnswerRe: .net Query Pin
Gerry Schmitz7-Aug-14 11:00
mveGerry Schmitz7-Aug-14 11:00 
QuestionConnecting to License Application on Server Pin
Jassim Rahma6-Aug-14 20:25
Jassim Rahma6-Aug-14 20:25 
AnswerRe: Connecting to License Application on Server Pin
Bernhard Hiller6-Aug-14 20:39
Bernhard Hiller6-Aug-14 20:39 
QuestionSame EXE vs Different EXE Pin
KUMAR6196-Aug-14 19:36
professionalKUMAR6196-Aug-14 19:36 
AnswerRe: Same EXE vs Different EXE Pin
Akhil Mittal6-Aug-14 20:05
professionalAkhil Mittal6-Aug-14 20:05 
AnswerRe: Same EXE vs Different EXE Pin
Bernhard Hiller6-Aug-14 20:43
Bernhard Hiller6-Aug-14 20:43 
AnswerRe: Same EXE vs Different EXE Pin
Mycroft Holmes6-Aug-14 21:54
professionalMycroft Holmes6-Aug-14 21:54 
GeneralRe: Same EXE vs Different EXE Pin
KUMAR6196-Aug-14 23:06
professionalKUMAR6196-Aug-14 23:06 
GeneralRe: Same EXE vs Different EXE Pin
Mycroft Holmes6-Aug-14 23:10
professionalMycroft Holmes6-Aug-14 23:10 
GeneralRe: Same EXE vs Different EXE Pin
KUMAR6196-Aug-14 23:49
professionalKUMAR6196-Aug-14 23:49 
GeneralRe: Same EXE vs Different EXE PinPopular
Mycroft Holmes7-Aug-14 0:57
professionalMycroft Holmes7-Aug-14 0:57 
GeneralRe: Same EXE vs Different EXE PinPopular
GuyThiebaut7-Aug-14 2:44
professionalGuyThiebaut7-Aug-14 2:44 
GeneralRe: Same EXE vs Different EXE Pin
Bernhard Hiller7-Aug-14 21:11
Bernhard Hiller7-Aug-14 21:11 
AnswerRe: Same EXE vs Different EXE Pin
Akhil Mittal7-Aug-14 20:05
professionalAkhil Mittal7-Aug-14 20:05 
QuestionCall a SAP transaction, execute with given parameters and download a report with C# Pin
Goliadkin6-Aug-14 16:41
Goliadkin6-Aug-14 16:41 
AnswerRe: Call a SAP transaction, execute with given parameters and download a report with C# Pin
Goliadkin7-Aug-14 15:07
Goliadkin7-Aug-14 15:07 
QuestionXML usage Pin
eblaschka6-Aug-14 14:26
eblaschka6-Aug-14 14:26 
AnswerRe: XML usage Pin
Dave Kreskowiak6-Aug-14 17:08
mveDave Kreskowiak6-Aug-14 17:08 
AnswerRe: XML usage Pin
Bernhard Hiller6-Aug-14 20:49
Bernhard Hiller6-Aug-14 20:49 
AnswerRe: XML usage Pin
Richard Deeming7-Aug-14 1:35
mveRichard Deeming7-Aug-14 1:35 
GeneralRe: XML usage Pin
eblaschka10-Aug-14 11:39
eblaschka10-Aug-14 11:39 
Hi
This is driving me nuts.
Besides my first structure containing "drive" information, I also have a registry content XML file.
I thought I'd just apply some analogy and it sort of works but for some reason I do not seem to be able to dig deeper into the structure than <value> but I would like to get the value of <action>, <type> and <content> (inside if <value> too.

So here is the structure:

HTML


XML
<Registry>
        <RootKey>
          <Name>HKEY_LOCAL_MACHINE</Name>
          <Action>None</Action>
          <ContainedKeys>
            <Key>
              <Name>SOFTWARE</Name>
              <Action>None</Action>
              <ContainedKeys>
                <Key>
                  <Name>Classes</Name>
                  <Action>None</Action>
                  <ContainedKeys>
                    <Key>
                      <Name>Installer</Name>
                      <Action>None</Action>
                      <ContainedKeys>
                        <Key>
                          <Name>Features</Name>
                          <Action>None</Action>
                          <ContainedKeys>
                            <Key>
                              <Name>8CD5D2FB0DBCDD64A8D2AB1D09CAF271</Name>
                              <Action>Created</Action>
                              <ContainedValues>
                                <Value>
                                  <Name>ClientPrograms</Name>
                                  <Action>Created</Action>
                                  <After>
                                    <Data>
                                      <Type>REG_SZ</Type>
                                      <Contents></Contents>
                                    </Data>
                                  </After>
                                </Value>
                                <Value>
                                  <Name>DataFiles</Name>
                                  <Action>Created</Action>
                                  <After>
                                    <Data>
                                      <Type>REG_SZ</Type>
                                      <Contents>Server</Contents>
                                    </Data>
                                  </After>
                                </Value>







Using the example that Richard gave, my code is:

C#
<pre

     IList<string> Regs = document.Descendants("Value").Select(GetFullPathtoKey).ToList();
        

         static string GetFullPathtoKey(XElement fileElement)
        {
            var names = new HashSet<XName> { "RootKey", "Key", "Value","Type", "Name", "Data", "Contents" };

            IEnumerable<string> pathParts = fileElement.AncestorsAndSelf()
           .Where(el => names.Contains(el.Name))
           .Select(el => (string)el.Element("Name"))
           .Reverse();
            return string.Join("\\", pathParts);
        }

<pre lang="text">

That works fine and a list entry is for instance:

HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Features\8CD5D2FB0DBCDD64A8D2AB1D09CAF271\ClientPrograms



But if I extend the Path to include , it will just not work:
Like:

C#
<pre
   IList<string> Regs = document.Descendants("Data").Select(GetFullPathtoKey).ToList();
        

      

         static string GetFullPathtoKey(XElement fileElement)
        {
            var names = new HashSet<XName> { "RootKey", "Key", "Value","Type", "Name", "Data", "Contents" };

            IEnumerable<string> pathParts = fileElement.AncestorsAndSelf()
           .Where(el => names.Contains(el.Name))
           .Select(el => (string)el.Element("Contents"))
           .Reverse();
            return string.Join("\\", pathParts);
        }

<pre lang="text">


will give \\\\\\\\ for the first entry and
\\\\\\\Server for the second.


No I can create three lists for the path with Value, the Action and the Content, but that seems to be overkill.

After extracting the Path: "HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Installer\Features\8CD5D2FB0DBCDD64A8D2AB1D09CAF271\ClientPrograms"

how can I derive easily the Action, Type and the Content???

I have been piddling with this for the whole weekend without success. I guess I do not understand what the difference is
between the path to <value> and the path to . Confused | :confused:

Thanks a lot for any help!!!!

GeneralRe: XML usage Pin
Richard Deeming11-Aug-14 1:53
mveRichard Deeming11-Aug-14 1:53 
GeneralRe: XML usage Pin
eblaschka12-Aug-14 4:42
eblaschka12-Aug-14 4:42 
GeneralRe: XML usage Pin
eblaschka12-Aug-14 11:14
eblaschka12-Aug-14 11:14 

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.