Click here to Skip to main content
15,886,572 members
Home / Discussions / C#
   

C#

 
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 
AnswerThank you! Pin
eblaschka7-Aug-14 13:03
eblaschka7-Aug-14 13:03 
GeneralRe: Thank you! Pin
Dave Kreskowiak7-Aug-14 16:51
mveDave Kreskowiak7-Aug-14 16:51 
AnswerThank you! Pin
eblaschka7-Aug-14 15:49
eblaschka7-Aug-14 15:49 
GeneralRe: Thank you! Pin
Richard Deeming8-Aug-14 2:09
mveRichard Deeming8-Aug-14 2:09 
AnswerRe: XML usage Pin
PIEBALDconsult7-Aug-14 16:43
mvePIEBALDconsult7-Aug-14 16:43 
QuestionSend Email Notifications from Server Pin
Jassim Rahma6-Aug-14 11:28
Jassim Rahma6-Aug-14 11:28 
AnswerRe: Send Email Notifications from Server Pin
Bernhard Hiller6-Aug-14 20:54
Bernhard Hiller6-Aug-14 20:54 
GeneralRe: Send Email Notifications from Server Pin
Jassim Rahma10-Aug-14 10:19
Jassim Rahma10-Aug-14 10:19 
GeneralRe: Send Email Notifications from Server Pin
Bernhard Hiller10-Aug-14 20:06
Bernhard Hiller10-Aug-14 20:06 
Question.net framework Pin
Member 109952356-Aug-14 1:07
Member 109952356-Aug-14 1:07 
AnswerRe: .net framework PinPopular
Pete O'Hanlon6-Aug-14 1:09
mvePete O'Hanlon6-Aug-14 1:09 
GeneralRe: .net framework Pin
Joe Woodbury6-Aug-14 14:00
professionalJoe Woodbury6-Aug-14 14:00 
AnswerRe: .net framework Pin
Akhil Mittal6-Aug-14 20:07
professionalAkhil Mittal6-Aug-14 20:07 
QuestionAfter Call Through WebAPI, Entity Is Null Pin
Kevin Marois5-Aug-14 8:14
professionalKevin Marois5-Aug-14 8: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.