Click here to Skip to main content
14,484,535 members
Rate this:
Please Sign up or sign in to vote.
See more:
I have been looking for the solution for the last 4 hours and have found a few pieces that help me read a standardized xml file, but doesn't allow me to read this.

I am also trying to store the parent node where "key="(not null)"" so it can't be Key="".

I am trying to pull what Key equals and the parent element from that.
I would really appreciate any help because this has been exhausting.
Thank you in advance.

<setspeed100>
	<primary device="Keyboard" key="Key_Numpad_4">
	<secondary device="{NoDevice}" key="">

<yawaxis_landing>
	<binding device="{NoDevice}" key="">
	<inverted value="0">
	<deadzone value="0.00000000">


What I have tried:

<pre lang="C#"> XmlDocument xmlDoc = new XmlDocument();
    var edXML = GetEDBindingsPath();
    var xml = XElement.Load(edXML);


That is as far as I've gotten because everything else uses a standardized format. 
Example of what I mean by standardized...


< Users >
  < User >
    < Name > John Smith </ Name >
    < test >
      < Date > 23.05.2011 </ Date >
      < points > 33 </ points >
    </ test >
    < test >
      < Date > 22.06.2011 </ Date >
      < points > 29 </ points >
    </ test >
  </ User >
</ Users >
Posted
Updated 19-Oct-16 21:59pm
Comments
johannesnestler 19-Oct-16 8:52am
   
So with XML we mean a well formed XML document - lot's of code availabe to deal with this - you don't have XML here so you have to write your own parser - why did you think it was a good idea to treat this as XML in the first place (because it looks like XML from far away?
antaresinsomnious 19-Oct-16 9:50am
   
Every XML Checker I ran it through said it was, but I am unfamiliar with XML. I figured it was since it's from a game developer. I figured that since they put at the top they knew what they was writing.
I almost got it figured out though(With my own parser), I just don't know why it lets certain things pass through...
Rate this:
Please Sign up or sign in to vote.

Solution 6

The way I got it to work.

internal void ReadEDKeyBindings()
        {
            string edKB = GetEDBindingsPath();
            List<string> list = new List<string>();
            List<string> parent = new List<string>();
            List<string> child = new List<string>();
            XDocument doc = XDocument.Load(edKB);
            var allElements = doc.Descendants();

            //var matchingElements = doc.Descendants()
            //    .Where(x => x.Attribute("Key") != null);


            foreach (var a in allElements)
            {
                string str = a.ToString();
                string[] pPart = str.Split(new[] { '\r' });
                foreach (string p in pPart)
                {
                    list.Add(p);
                }
            }

            foreach (string l in list)
            {
                if (!l.Contains("Buggy"))
                {
                    if (l.Contains("Key") && (!l.Contains("Modifier") && (!l.Contains("Secondary") && (!l.Contains("Joy")))))
                    {
                        try
                        {
                            string[] parts = l.Split(new[] { ' ' });
                            string sub = parts[6].Substring(5);
                            int last = sub.Length - 1;
                            sub = sub.Substring(0, last);
                            if (sub != "")
                            {
                                int index = list.IndexOf(l);

                                string tmp1 = list[index - 1];

                                string tmp2 = tmp1.Substring(4);
                                int iTmp = tmp2.Length - 1;
                                string p = tmp2.Substring(0, iTmp);
                                parent.Add(p);
                                child.Add(sub);
                            }
                        }
                        catch
                        {

                        }
                    }
                }
            }
            //for (int i = 0; i < parent.Count(); i++)
            //{
            //    Console.WriteLine("Index = " + i + " :  Parent : " + parent[i] + " : Child : " + child[i]);
            //    //Console.ReadKey();
            //}
            //Console.ReadKey();
        }
   
Rate this:
Please Sign up or sign in to vote.

Solution 5

This is the full "XML". The link I posted broke for some reason.

<?xml version="1.0" encoding="UTF-8" ?>
<Root PresetName="Custom" MajorVersion="1" MinorVersion="8">
	<KeyboardLayout>en-US</KeyboardLayout>
	<LockedDevice>{NoDevice}</LockedDevice>
	<MouseXMode Value="Bindings_MouseRoll" />
	<MouseXDecay Value="0" />
	<MouseYMode Value="Bindings_MousePitch" />
	<MouseYDecay Value="0" />
	<MouseReset>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</MouseReset>
	<MouseSensitivity Value="1.00000000" />
	<MouseDecayRate Value="4.00000000" />
	<MouseDeadzone Value="0.05000000" />
	<MouseLinearity Value="1.00000000" />
	<MouseGUI Value="1" />
	<YawAxisRaw>
		<Binding Device="{NoDevice}" Key="" />
		<Inverted Value="0" />
		<Deadzone Value="0.00000000" />
	</YawAxisRaw>
	<YawLeftButton>
		<Primary Device="Keyboard" Key="Key_A" />
		<Secondary Device="{NoDevice}" Key="" />
	</YawLeftButton>
	<YawRightButton>
		<Primary Device="Keyboard" Key="Key_D" />
		<Secondary Device="{NoDevice}" Key="" />
	</YawRightButton>
	<YawToRollMode Value="Bindings_YawIntoRollNone" />
	<YawToRollSensitivity Value="0.40000001" />
	<YawToRollButton>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
		<ToggleOn Value="0" />
	</YawToRollButton>
	<RollAxisRaw>
		<Binding Device="{NoDevice}" Key="" />
		<Inverted Value="0" />
		<Deadzone Value="0.00000000" />
	</RollAxisRaw>
	<RollLeftButton>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</RollLeftButton>
	<RollRightButton>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</RollRightButton>
	<PitchAxisRaw>
		<Binding Device="{NoDevice}" Key="" />
		<Inverted Value="0" />
		<Deadzone Value="0.00000000" />
	</PitchAxisRaw>
	<PitchUpButton>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</PitchUpButton>
	<PitchDownButton>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</PitchDownButton>
	<LateralThrustRaw>
		<Binding Device="{NoDevice}" Key="" />
		<Inverted Value="0" />
		<Deadzone Value="0.00000000" />
	</LateralThrustRaw>
	<LeftThrustButton>
		<Primary Device="Keyboard" Key="Key_Q" />
		<Secondary Device="{NoDevice}" Key="" />
	</LeftThrustButton>
	<RightThrustButton>
		<Primary Device="Keyboard" Key="Key_E" />
		<Secondary Device="{NoDevice}" Key="" />
	</RightThrustButton>
	<VerticalThrustRaw>
		<Binding Device="{NoDevice}" Key="" />
		<Inverted Value="0" />
		<Deadzone Value="0.00000000" />
	</VerticalThrustRaw>
	<UpThrustButton>
		<Primary Device="Keyboard" Key="Key_R" />
		<Secondary Device="{NoDevice}" Key="" />
	</UpThrustButton>
	<DownThrustButton>
		<Primary Device="Keyboard" Key="Key_F" />
		<Secondary Device="{NoDevice}" Key="" />
	</DownThrustButton>
	<AheadThrust>
		<Binding Device="{NoDevice}" Key="" />
		<Inverted Value="0" />
		<Deadzone Value="0.00000000" />
	</AheadThrust>
	<ForwardThrustButton>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</ForwardThrustButton>
	<BackwardThrustButton>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</BackwardThrustButton>
	<YawAxisAlternate>
		<Binding Device="{NoDevice}" Key="" />
		<Inverted Value="0" />
		<Deadzone Value="0.00000000" />
	</YawAxisAlternate>
	<RollAxisAlternate>
		<Binding Device="{NoDevice}" Key="" />
		<Inverted Value="0" />
		<Deadzone Value="0.00000000" />
	</RollAxisAlternate>
	<PitchAxisAlternate>
		<Binding Device="{NoDevice}" Key="" />
		<Inverted Value="0" />
		<Deadzone Value="0.00000000" />
	</PitchAxisAlternate>
	<LateralThrustAlternate>
		<Binding Device="{NoDevice}" Key="" />
		<Inverted Value="0" />
		<Deadzone Value="0.00000000" />
	</LateralThrustAlternate>
	<VerticalThrustAlternate>
		<Binding Device="{NoDevice}" Key="" />
		<Inverted Value="0" />
		<Deadzone Value="0.00000000" />
	</VerticalThrustAlternate>
	<UseAlternateFlightValuesToggle>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
		<ToggleOn Value="1" />
	</UseAlternateFlightValuesToggle>
	<ThrottleAxis>
		<Binding Device="{NoDevice}" Key="" />
		<Inverted Value="0" />
		<Deadzone Value="0.00000000" />
	</ThrottleAxis>
	<ThrottleRange Value="" />
	<ToggleReverseThrottleInput>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
		<ToggleOn Value="1" />
	</ToggleReverseThrottleInput>
	<ForwardKey>
		<Primary Device="Keyboard" Key="Key_W" />
		<Secondary Device="{NoDevice}" Key="" />
	</ForwardKey>
	<BackwardKey>
		<Primary Device="Keyboard" Key="Key_S" />
		<Secondary Device="{NoDevice}" Key="" />
	</BackwardKey>
	<ThrottleIncrement Value="0.00000000" />
	<SetSpeedMinus100>
		<Primary Device="Keyboard" Key="Key_Numpad_9" />
		<Secondary Device="{NoDevice}" Key="" />
	</SetSpeedMinus100>
	<SetSpeedMinus75>
		<Primary Device="Keyboard" Key="Key_Numpad_8" />
		<Secondary Device="{NoDevice}" Key="" />
	</SetSpeedMinus75>
	<SetSpeedMinus50>
		<Primary Device="Keyboard" Key="Key_Numpad_7" />
		<Secondary Device="{NoDevice}" Key="" />
	</SetSpeedMinus50>
	<SetSpeedMinus25>
		<Primary Device="Keyboard" Key="Key_Numpad_6" />
		<Secondary Device="{NoDevice}" Key="" />
	</SetSpeedMinus25>
	<SetSpeedZero>
		<Primary Device="Keyboard" Key="Key_Numpad_0" />
		<Secondary Device="{NoDevice}" Key="" />
	</SetSpeedZero>
	<SetSpeed25>
		<Primary Device="Keyboard" Key="Key_Numpad_1" />
		<Secondary Device="{NoDevice}" Key="" />
	</SetSpeed25>
	<SetSpeed50>
		<Primary Device="Keyboard" Key="Key_Numpad_2" />
		<Secondary Device="{NoDevice}" Key="" />
	</SetSpeed50>
	<SetSpeed75>
		<Primary Device="Keyboard" Key="Key_Numpad_3" />
		<Secondary Device="{NoDevice}" Key="" />
	</SetSpeed75>
	<SetSpeed100>
		<Primary Device="Keyboard" Key="Key_Numpad_4" />
		<Secondary Device="{NoDevice}" Key="" />
	</SetSpeed100>
	<YawAxis_Landing>
		<Binding Device="{NoDevice}" Key="" />
		<Inverted Value="0" />
		<Deadzone Value="0.00000000" />
	</YawAxis_Landing>
	<YawLeftButton_Landing>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</YawLeftButton_Landing>
	<YawRightButton_Landing>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</YawRightButton_Landing>
	<YawToRollMode_Landing Value="" />
	<PitchAxis_Landing>
		<Binding Device="{NoDevice}" Key="" />
		<Inverted Value="0" />
		<Deadzone Value="0.00000000" />
	</PitchAxis_Landing>
	<PitchUpButton_Landing>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</PitchUpButton_Landing>
	<PitchDownButton_Landing>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</PitchDownButton_Landing>
	<RollAxis_Landing>
		<Binding Device="{NoDevice}" Key="" />
		<Inverted Value="0" />
		<Deadzone Value="0.00000000" />
	</RollAxis_Landing>
	<RollLeftButton_Landing>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</RollLeftButton_Landing>
	<RollRightButton_Landing>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</RollRightButton_Landing>
	<LateralThrust_Landing>
		<Binding Device="{NoDevice}" Key="" />
		<Inverted Value="0" />
		<Deadzone Value="0.00000000" />
	</LateralThrust_Landing>
	<LeftThrustButton_Landing>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</LeftThrustButton_Landing>
	<RightThrustButton_Landing>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</RightThrustButton_Landing>
	<VerticalThrust_Landing>
		<Binding Device="{NoDevice}" Key="" />
		<Inverted Value="0" />
		<Deadzone Value="0.00000000" />
	</VerticalThrust_Landing>
	<UpThrustButton_Landing>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</UpThrustButton_Landing>
	<DownThrustButton_Landing>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</DownThrustButton_Landing>
	<AheadThrust_Landing>
		<Binding Device="{NoDevice}" Key="" />
		<Inverted Value="0" />
		<Deadzone Value="0.00000000" />
	</AheadThrust_Landing>
	<ForwardThrustButton_Landing>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</ForwardThrustButton_Landing>
	<BackwardThrustButton_Landing>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</BackwardThrustButton_Landing>
	<ToggleFlightAssist>
		<Primary Device="Keyboard" Key="Key_Z" />
		<Secondary Device="{NoDevice}" Key="" />
		<ToggleOn Value="0" />
	</ToggleFlightAssist>
	<YawToRollMode_FAOff Value="" />
	<UseBoostJuice>
		<Primary Device="Keyboard" Key="Key_Tab" />
		<Secondary Device="{NoDevice}" Key="" />
	</UseBoostJuice>
	<HyperSuperCombination>
		<Primary Device="Keyboard" Key="Key_J" />
		<Secondary Device="{NoDevice}" Key="" />
	</HyperSuperCombination>
	<Supercruise>
		<Primary Device="Keyboard" Key="Key_Numpad_Subtract" />
		<Secondary Device="{NoDevice}" Key="" />
	</Supercruise>
	<Hyperspace>
		<Primary Device="Keyboard" Key="Key_Numpad_Add" />
		<Secondary Device="{NoDevice}" Key="" />
	</Hyperspace>
	<DisableRotationCorrectToggle>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
		<ToggleOn Value="1" />
	</DisableRotationCorrectToggle>
	<OrbitLinesToggle>
		<Primary Device="Keyboard" Key="Key_Equals" />
		<Secondary Device="{NoDevice}" Key="" />
	</OrbitLinesToggle>
	<SelectTarget>
		<Primary Device="Keyboard" Key="Key_T" />
		<Secondary Device="{NoDevice}" Key="" />
	</SelectTarget>
	<CycleNextTarget>
		<Primary Device="Keyboard" Key="Key_Period" />
		<Secondary Device="{NoDevice}" Key="" />
	</CycleNextTarget>
	<CyclePreviousTarget>
		<Primary Device="Keyboard" Key="Key_Comma" />
		<Secondary Device="{NoDevice}" Key="" />
	</CyclePreviousTarget>
	<SelectHighestThreat>
		<Primary Device="Keyboard" Key="Key_H" />
		<Secondary Device="{NoDevice}" Key="" />
	</SelectHighestThreat>
	<CycleNextHostileTarget>
		<Primary Device="Keyboard" Key="Key_SemiColon" />
		<Secondary Device="{NoDevice}" Key="" />
	</CycleNextHostileTarget>
	<CyclePreviousHostileTarget>
		<Primary Device="Keyboard" Key="Key_Apostrophe" />
		<Secondary Device="{NoDevice}" Key="" />
	</CyclePreviousHostileTarget>
	<TargetWingman0>
		<Primary Device="Keyboard" Key="Key_7" />
		<Secondary Device="{NoDevice}" Key="" />
	</TargetWingman0>
	<TargetWingman1>
		<Primary Device="Keyboard" Key="Key_8" />
		<Secondary Device="{NoDevice}" Key="" />
	</TargetWingman1>
	<TargetWingman2>
		<Primary Device="Keyboard" Key="Key_9" />
		<Secondary Device="{NoDevice}" Key="" />
	</TargetWingman2>
	<SelectTargetsTarget>
		<Primary Device="Keyboard" Key="Key_0" />
		<Secondary Device="{NoDevice}" Key="" />
	</SelectTargetsTarget>
	<WingNavLock>
		<Primary Device="Keyboard" Key="Key_Minus" />
		<Secondary Device="{NoDevice}" Key="" />
	</WingNavLock>
	<CycleNextSubsystem>
		<Primary Device="Keyboard" Key="Key_Y" />
		<Secondary Device="{NoDevice}" Key="" />
	</CycleNextSubsystem>
	<CyclePreviousSubsystem>
		<Primary Device="Keyboard" Key="Key_B" />
		<Secondary Device="{NoDevice}" Key="" />
	</CyclePreviousSubsystem>
	<TargetNextRouteSystem>
		<Primary Device="Keyboard" Key="Key_Numpad_5" />
		<Secondary Device="{NoDevice}" Key="" />
	</TargetNextRouteSystem>
	<PrimaryFire>
		<Primary Device="Mouse" Key="Mouse_1" />
		<Secondary Device="{NoDevice}" Key="" />
	</PrimaryFire>
	<SecondaryFire>
		<Primary Device="Mouse" Key="Mouse_2" />
		<Secondary Device="{NoDevice}" Key="" />
	</SecondaryFire>
	<CycleFireGroupNext>
		<Primary Device="Keyboard" Key="Key_N" />
		<Secondary Device="{NoDevice}" Key="" />
	</CycleFireGroupNext>
	<CycleFireGroupPrevious>
		<Primary Device="Keyboard" Key="Key_M" />
		<Secondary Device="{NoDevice}" Key="" />
	</CycleFireGroupPrevious>
	<DeployHardpointToggle>
		<Primary Device="Keyboard" Key="Key_U" />
		<Secondary Device="{NoDevice}" Key="" />
	</DeployHardpointToggle>
	<DeployHardpointsOnFire Value="1" />
	<ToggleButtonUpInput>
		<Primary Device="Keyboard" Key="Key_Delete" />
		<Secondary Device="{NoDevice}" Key="" />
		<ToggleOn Value="1" />
	</ToggleButtonUpInput>
	<DeployHeatSink>
		<Primary Device="Keyboard" Key="Key_V" />
		<Secondary Device="{NoDevice}" Key="" />
	</DeployHeatSink>
	<ShipSpotLightToggle>
		<Primary Device="Keyboard" Key="Key_Insert" />
		<Secondary Device="{NoDevice}" Key="" />
	</ShipSpotLightToggle>
	<RadarRangeAxis>
		<Binding Device="{NoDevice}" Key="" />
		<Inverted Value="0" />
		<Deadzone Value="0.00000000" />
	</RadarRangeAxis>
	<RadarIncreaseRange>
		<Primary Device="Keyboard" Key="Key_PageUp" />
		<Secondary Device="{NoDevice}" Key="" />
	</RadarIncreaseRange>
	<RadarDecreaseRange>
		<Primary Device="Keyboard" Key="Key_PageDown" />
		<Secondary Device="{NoDevice}" Key="" />
	</RadarDecreaseRange>
	<IncreaseEnginesPower>
		<Primary Device="Keyboard" Key="Key_UpArrow" />
		<Secondary Device="{NoDevice}" Key="" />
	</IncreaseEnginesPower>
	<IncreaseWeaponsPower>
		<Primary Device="Keyboard" Key="Key_RightArrow" />
		<Secondary Device="{NoDevice}" Key="" />
	</IncreaseWeaponsPower>
	<IncreaseSystemsPower>
		<Primary Device="Keyboard" Key="Key_LeftArrow" />
		<Secondary Device="{NoDevice}" Key="" />
	</IncreaseSystemsPower>
	<ResetPowerDistribution>
		<Primary Device="Keyboard" Key="Key_DownArrow" />
		<Secondary Device="{NoDevice}" Key="" />
	</ResetPowerDistribution>
	<HMDReset>
		<Primary Device="Keyboard" Key="Key_F12" />
		<Secondary Device="{NoDevice}" Key="" />
	</HMDReset>
	<ToggleCargoScoop>
		<Primary Device="Keyboard" Key="Key_Home" />
		<Secondary Device="{NoDevice}" Key="" />
		<ToggleOn Value="1" />
	</ToggleCargoScoop>
	<EjectAllCargo>
		<Primary Device="Keyboard" Key="Key_End" />
		<Secondary Device="{NoDevice}" Key="" />
	</EjectAllCargo>
	<LandingGearToggle>
		<Primary Device="Keyboard" Key="Key_L" />
		<Secondary Device="{NoDevice}" Key="" />
	</LandingGearToggle>
	<MicrophoneMute>
		<Primary Device="Keyboard" Key="Key_BackSlash" />
		<Secondary Device="{NoDevice}" Key="" />
	</MicrophoneMute>
	<MuteButtonMode Value="mute_toggle" />
	<CqcMuteButtonMode Value="mute_pushToTalk" />
	<UseShieldCell>
		<Primary Device="Keyboard" Key="Key_C" />
		<Secondary Device="{NoDevice}" Key="" />
	</UseShieldCell>
	<FireChaffLauncher>
		<Primary Device="Keyboard" Key="Key_K" />
		<Secondary Device="{NoDevice}" Key="" />
	</FireChaffLauncher>
	<PhotoCameraToggle>
		<Primary Device="Keyboard" Key="Key_Space">
			<Modifier Device="Keyboard" Key="Key_LeftControl" />
			<Modifier Device="Keyboard" Key="Key_LeftAlt" />
		</Primary>
		<Secondary Device="{NoDevice}" Key="" />
	</PhotoCameraToggle>
	<EnableMenuGroups Value="0" />
	<UIFocus>
		<Primary Device="Keyboard" Key="Key_LeftShift" />
		<Secondary Device="{NoDevice}" Key="" />
	</UIFocus>
	<UIFocusMode Value="Bindings_FocusModeHold" />
	<FocusLeftPanel>
		<Primary Device="Keyboard" Key="Key_1" />
		<Secondary Device="{NoDevice}" Key="" />
	</FocusLeftPanel>
	<FocusCommsPanel>
		<Primary Device="Keyboard" Key="Key_2" />
		<Secondary Device="{NoDevice}" Key="" />
	</FocusCommsPanel>
	<FocusOnTextEntryField Value="0" />
	<QuickCommsPanel>
		<Primary Device="Keyboard" Key="Key_Enter" />
		<Secondary Device="{NoDevice}" Key="" />
	</QuickCommsPanel>
	<FocusRadarPanel>
		<Primary Device="Keyboard" Key="Key_3" />
		<Secondary Device="{NoDevice}" Key="" />
	</FocusRadarPanel>
	<FocusRightPanel>
		<Primary Device="Keyboard" Key="Key_4" />
		<Secondary Device="{NoDevice}" Key="" />
	</FocusRightPanel>
	<LeftPanelFocusOptions Value="" />
	<CommsPanelFocusOptions Value="FocusOption_Show" />
	<RolePanelFocusOptions Value="" />
	<RightPanelFocusOptions Value="" />
	<EnableCameraLockOn Value="1" />
	<GalaxyMapOpen>
		<Primary Device="Keyboard" Key="Key_Numpad_Divide" />
		<Secondary Device="{NoDevice}" Key="" />
	</GalaxyMapOpen>
	<SystemMapOpen>
		<Primary Device="Keyboard" Key="Key_Numpad_Multiply" />
		<Secondary Device="{NoDevice}" Key="" />
	</SystemMapOpen>
	<ShowPGScoreSummaryInput>
		<Primary Device="Keyboard" Key="Key_F1" />
		<Secondary Device="{NoDevice}" Key="" />
		<ToggleOn Value="0" />
	</ShowPGScoreSummaryInput>
	<HeadLookToggle>
		<Primary Device="Mouse" Key="Mouse_3" />
		<Secondary Device="{NoDevice}" Key="" />
		<ToggleOn Value="1" />
	</HeadLookToggle>
	<Pause>
		<Primary Device="Keyboard" Key="Key_P" />
		<Secondary Device="{NoDevice}" Key="" />
	</Pause>
	<UI_Up>
		<Primary Device="Keyboard" Key="Key_W" />
		<Secondary Device="{NoDevice}" Key="" />
	</UI_Up>
	<UI_Down>
		<Primary Device="Keyboard" Key="Key_S" />
		<Secondary Device="{NoDevice}" Key="" />
	</UI_Down>
	<UI_Left>
		<Primary Device="Keyboard" Key="Key_A" />
		<Secondary Device="{NoDevice}" Key="" />
	</UI_Left>
	<UI_Right>
		<Primary Device="Keyboard" Key="Key_D" />
		<Secondary Device="{NoDevice}" Key="" />
	</UI_Right>
	<UI_Select>
		<Primary Device="Keyboard" Key="Key_Space" />
		<Secondary Device="{NoDevice}" Key="" />
	</UI_Select>
	<UI_Back>
		<Primary Device="Keyboard" Key="Key_Backspace" />
		<Secondary Device="Mouse" Key="Mouse_2" />
	</UI_Back>
	<UI_Toggle>
		<Primary Device="Keyboard" Key="Key_Equals" />
		<Secondary Device="{NoDevice}" Key="" />
	</UI_Toggle>
	<CycleNextPanel>
		<Primary Device="Keyboard" Key="Key_E" />
		<Secondary Device="{NoDevice}" Key="" />
	</CycleNextPanel>
	<CyclePreviousPanel>
		<Primary Device="Keyboard" Key="Key_Q" />
		<Secondary Device="{NoDevice}" Key="" />
	</CyclePreviousPanel>
	<MouseHeadlook Value="1" />
	<MouseHeadlookInvert Value="0" />
	<MouseHeadlookSensitivity Value="0.50000000" />
	<HeadlookDefault Value="0" />
	<HeadlookIncrement Value="0.00000000" />
	<HeadlookMode Value="Bindings_HeadlookModeAccumulate" />
	<HeadlookResetOnToggle Value="1" />
	<HeadlookSensitivity Value="1.00000000" />
	<HeadLookReset>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</HeadLookReset>
	<HeadLookPitchUp>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</HeadLookPitchUp>
	<HeadLookPitchDown>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</HeadLookPitchDown>
	<HeadLookPitchAxisRaw>
		<Binding Device="{NoDevice}" Key="" />
		<Inverted Value="0" />
		<Deadzone Value="0.00000000" />
	</HeadLookPitchAxisRaw>
	<HeadLookYawLeft>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</HeadLookYawLeft>
	<HeadLookYawRight>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</HeadLookYawRight>
	<HeadLookYawAxis>
		<Binding Device="{NoDevice}" Key="" />
		<Inverted Value="0" />
		<Deadzone Value="0.00000000" />
	</HeadLookYawAxis>
	<CamPitchAxis>
		<Binding Device="{NoDevice}" Key="" />
		<Inverted Value="0" />
		<Deadzone Value="0.00000000" />
	</CamPitchAxis>
	<CamPitchUp>
		<Primary Device="Keyboard" Key="Key_T" />
		<Secondary Device="{NoDevice}" Key="" />
	</CamPitchUp>
	<CamPitchDown>
		<Primary Device="Keyboard" Key="Key_G" />
		<Secondary Device="{NoDevice}" Key="" />
	</CamPitchDown>
	<CamYawAxis>
		<Binding Device="{NoDevice}" Key="" />
		<Inverted Value="0" />
		<Deadzone Value="0.00000000" />
	</CamYawAxis>
	<CamYawLeft>
		<Primary Device="Keyboard" Key="Key_Q" />
		<Secondary Device="{NoDevice}" Key="" />
	</CamYawLeft>
	<CamYawRight>
		<Primary Device="Keyboard" Key="Key_E" />
		<Secondary Device="{NoDevice}" Key="" />
	</CamYawRight>
	<CamTranslateYAxis>
		<Binding Device="{NoDevice}" Key="" />
		<Inverted Value="0" />
		<Deadzone Value="0.00000000" />
	</CamTranslateYAxis>
	<CamTranslateForward>
		<Primary Device="Keyboard" Key="Key_W" />
		<Secondary Device="{NoDevice}" Key="" />
	</CamTranslateForward>
	<CamTranslateBackward>
		<Primary Device="Keyboard" Key="Key_S" />
		<Secondary Device="{NoDevice}" Key="" />
	</CamTranslateBackward>
	<CamTranslateXAxis>
		<Binding Device="{NoDevice}" Key="" />
		<Inverted Value="0" />
		<Deadzone Value="0.00000000" />
	</CamTranslateXAxis>
	<CamTranslateLeft>
		<Primary Device="Keyboard" Key="Key_A" />
		<Secondary Device="{NoDevice}" Key="" />
	</CamTranslateLeft>
	<CamTranslateRight>
		<Primary Device="Keyboard" Key="Key_D" />
		<Secondary Device="{NoDevice}" Key="" />
	</CamTranslateRight>
	<CamTranslateZAxis>
		<Binding Device="{NoDevice}" Key="" />
		<Inverted Value="0" />
		<Deadzone Value="0.00000000" />
	</CamTranslateZAxis>
	<CamTranslateUp>
		<Primary Device="Keyboard" Key="Key_R" />
		<Secondary Device="{NoDevice}" Key="" />
	</CamTranslateUp>
	<CamTranslateDown>
		<Primary Device="Keyboard" Key="Key_F" />
		<Secondary Device="{NoDevice}" Key="" />
	</CamTranslateDown>
	<CamZoomAxis>
		<Binding Device="{NoDevice}" Key="" />
		<Inverted Value="0" />
		<Deadzone Value="0.00000000" />
	</CamZoomAxis>
	<CamZoomIn>
		<Primary Device="Keyboard" Key="Key_Z" />
		<Secondary Device="{NoDevice}" Key="" />
	</CamZoomIn>
	<CamZoomOut>
		<Primary Device="Keyboard" Key="Key_X" />
		<Secondary Device="{NoDevice}" Key="" />
	</CamZoomOut>
	<CamTranslateZHold>
		<Primary Device="Keyboard" Key="Key_O" />
		<Secondary Device="{NoDevice}" Key="" />
		<ToggleOn Value="0" />
	</CamTranslateZHold>
	<ToggleDriveAssist>
		<Primary Device="Keyboard" Key="Key_Z" />
		<Secondary Device="{NoDevice}" Key="" />
		<ToggleOn Value="1" />
	</ToggleDriveAssist>
	<DriveAssistDefault Value="1" />
	<MouseBuggySteeringXMode Value="" />
	<MouseBuggySteeringXDecay Value="0" />
	<MouseBuggyRollingXMode Value="" />
	<MouseBuggyRollingXDecay Value="0" />
	<MouseBuggyYMode Value="" />
	<MouseBuggyYDecay Value="0" />
	<SteeringAxis>
		<Binding Device="{NoDevice}" Key="" />
		<Inverted Value="0" />
		<Deadzone Value="0.00000000" />
	</SteeringAxis>
	<SteerLeftButton>
		<Primary Device="Keyboard" Key="Key_A" />
		<Secondary Device="{NoDevice}" Key="" />
	</SteerLeftButton>
	<SteerRightButton>
		<Primary Device="Keyboard" Key="Key_D" />
		<Secondary Device="{NoDevice}" Key="" />
	</SteerRightButton>
	<BuggyRollAxisRaw>
		<Binding Device="{NoDevice}" Key="" />
		<Inverted Value="0" />
		<Deadzone Value="0.00000000" />
	</BuggyRollAxisRaw>
	<BuggyRollLeftButton>
		<Primary Device="Keyboard" Key="Key_A" />
		<Secondary Device="{NoDevice}" Key="" />
	</BuggyRollLeftButton>
	<BuggyRollRightButton>
		<Primary Device="Keyboard" Key="Key_D" />
		<Secondary Device="{NoDevice}" Key="" />
	</BuggyRollRightButton>
	<BuggyPitchAxis>
		<Binding Device="{NoDevice}" Key="" />
		<Inverted Value="0" />
		<Deadzone Value="0.00000000" />
	</BuggyPitchAxis>
	<BuggyPitchUpButton>
		<Primary Device="Keyboard" Key="Key_W" />
		<Secondary Device="{NoDevice}" Key="" />
	</BuggyPitchUpButton>
	<BuggyPitchDownButton>
		<Primary Device="Keyboard" Key="Key_S" />
		<Secondary Device="{NoDevice}" Key="" />
	</BuggyPitchDownButton>
	<VerticalThrustersButton>
		<Primary Device="Keyboard" Key="Key_Space" />
		<Secondary Device="{NoDevice}" Key="" />
		<ToggleOn Value="0" />
	</VerticalThrustersButton>
	<BuggyPrimaryFireButton>
		<Primary Device="Mouse" Key="Mouse_1" />
		<Secondary Device="{NoDevice}" Key="" />
	</BuggyPrimaryFireButton>
	<BuggySecondaryFireButton>
		<Primary Device="Mouse" Key="Mouse_2" />
		<Secondary Device="{NoDevice}" Key="" />
	</BuggySecondaryFireButton>
	<AutoBreakBuggyButton>
		<Primary Device="Keyboard" Key="Key_X" />
		<Secondary Device="{NoDevice}" Key="" />
		<ToggleOn Value="0" />
	</AutoBreakBuggyButton>
	<HeadlightsBuggyButton>
		<Primary Device="Keyboard" Key="Key_L" />
		<Secondary Device="{NoDevice}" Key="" />
	</HeadlightsBuggyButton>
	<ToggleBuggyTurretButton>
		<Primary Device="Keyboard" Key="Key_U" />
		<Secondary Device="{NoDevice}" Key="" />
	</ToggleBuggyTurretButton>
	<SelectTarget_Buggy>
		<Primary Device="Mouse" Key="Mouse_2" />
		<Secondary Device="{NoDevice}" Key="" />
	</SelectTarget_Buggy>
	<MouseTurretXMode Value="Bindings_MouseYaw" />
	<MouseTurretXDecay Value="1" />
	<MouseTurretYMode Value="Bindings_MousePitchInverted" />
	<MouseTurretYDecay Value="1" />
	<BuggyTurretYawAxisRaw>
		<Binding Device="{NoDevice}" Key="" />
		<Inverted Value="0" />
		<Deadzone Value="0.00000000" />
	</BuggyTurretYawAxisRaw>
	<BuggyTurretYawLeftButton>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</BuggyTurretYawLeftButton>
	<BuggyTurretYawRightButton>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</BuggyTurretYawRightButton>
	<BuggyTurretPitchAxisRaw>
		<Binding Device="{NoDevice}" Key="" />
		<Inverted Value="0" />
		<Deadzone Value="0.00000000" />
	</BuggyTurretPitchAxisRaw>
	<BuggyTurretPitchUpButton>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</BuggyTurretPitchUpButton>
	<BuggyTurretPitchDownButton>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</BuggyTurretPitchDownButton>
	<DriveSpeedAxis>
		<Binding Device="{NoDevice}" Key="" />
		<Inverted Value="0" />
		<Deadzone Value="0.00000000" />
	</DriveSpeedAxis>
	<BuggyThrottleRange Value="Bindings_BuggyThrottleForewardOnly" />
	<BuggyToggleReverseThrottleInput>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
		<ToggleOn Value="1" />
	</BuggyToggleReverseThrottleInput>
	<BuggyThrottleIncrement Value="0.00000000" />
	<IncreaseSpeedButtonMax>
		<Primary Device="Keyboard" Key="Key_E" />
		<Secondary Device="{NoDevice}" Key="" />
	</IncreaseSpeedButtonMax>
	<DecreaseSpeedButtonMax>
		<Primary Device="Keyboard" Key="Key_Q" />
		<Secondary Device="{NoDevice}" Key="" />
	</DecreaseSpeedButtonMax>
	<IncreaseSpeedButtonPartial>
		<Binding Device="{NoDevice}" Key="" />
		<Inverted Value="0" />
		<Deadzone Value="0.00000000" />
	</IncreaseSpeedButtonPartial>
	<DecreaseSpeedButtonPartial>
		<Binding Device="{NoDevice}" Key="" />
		<Inverted Value="0" />
		<Deadzone Value="0.00000000" />
	</DecreaseSpeedButtonPartial>
	<IncreaseEnginesPower_Buggy>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</IncreaseEnginesPower_Buggy>
	<IncreaseWeaponsPower_Buggy>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</IncreaseWeaponsPower_Buggy>
	<IncreaseSystemsPower_Buggy>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</IncreaseSystemsPower_Buggy>
	<ResetPowerDistribution_Buggy>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</ResetPowerDistribution_Buggy>
	<ToggleCargoScoop_Buggy>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
		<ToggleOn Value="0" />
	</ToggleCargoScoop_Buggy>
	<EjectAllCargo_Buggy>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</EjectAllCargo_Buggy>
	<PhotoCameraToggle_Buggy>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
		<ToggleOn Value="0" />
	</PhotoCameraToggle_Buggy>
	<UIFocus_Buggy>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</UIFocus_Buggy>
	<FocusLeftPanel_Buggy>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</FocusLeftPanel_Buggy>
	<FocusCommsPanel_Buggy>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</FocusCommsPanel_Buggy>
	<QuickCommsPanel_Buggy>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</QuickCommsPanel_Buggy>
	<FocusRadarPanel_Buggy>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</FocusRadarPanel_Buggy>
	<FocusRightPanel_Buggy>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</FocusRightPanel_Buggy>
	<GalaxyMapOpen_Buggy>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</GalaxyMapOpen_Buggy>
	<SystemMapOpen_Buggy>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
	</SystemMapOpen_Buggy>
	<HeadLookToggle_Buggy>
		<Primary Device="{NoDevice}" Key="" />
		<Secondary Device="{NoDevice}" Key="" />
		<ToggleOn Value="0" />
	</HeadLookToggle_Buggy>
</Root>
   
Comments
antaresinsomnious 20-Oct-16 0:23am
   
Indexes 59, 78, and 111 are the only 3 that bring back the full string, and I still can't seem to make it not do that.
Rate this:
Please Sign up or sign in to vote.

Solution 4

Here is the link to my "XML"

<script src='http://pastie.org/10946087.js'>
</script>


My code could use some work I know, it's kind of messy right now, but I am going to clean it up and find out how to shorten it some.

internal void ReadEDKeyBindings()
        {
            string edKB = GetEDBindingsPath();
            List<string> list = new List<string>();
            List<string> parent = new List<string>();
            List<string> child = new List<string>();
            XDocument doc = XDocument.Load(edKB);
            var allElements = doc.Descendants();

            var matchingElements = doc.Descendants()
                .Where(x => x.Attribute("Key") != null);


            foreach (var a in allElements)
            {
                string str = a.ToString();
                string[] pPart = str.Split(new[] { '\r' });
                foreach (string p in pPart)
                {
                    list.Add(p);
                }
            }
            foreach (string l in list)
            {
                if (!l.Contains("Buggy"))
                {
                    if (l.Contains("Key"))
                    {
                        try
                        {
                            string[] parts = l.Split(new[] { ' ' });
                            string sub = parts[6].Substring(5);
                            int last = sub.Length - 1;
                            sub = sub.Substring(0, last);
                            if (sub != "")
                            {
                                int index = list.IndexOf(l);

                                string tmp1 = list[index - 1];

                                string tmp2 = tmp1.Substring(4);
                                int iTmp = tmp2.Length - 1;
                                string p = tmp2.Substring(0, iTmp);
                                parent.Add(p);
                                child.Add(sub);
                            }
                        }
                        catch
                        {

                        }
                    }
                }
            }
            for (int i = 0; i < parent.Count(); i++)
            {
                Console.WriteLine("Index = " + i + " :  Parent : " + parent[i] + " : Child : " + child[i]);
            }
        }
   
Rate this:
Please Sign up or sign in to vote.

Solution 1

You could try the XmlReader Class (System.Xml)[^], but that does not look like well-formed XML, so you may still have problems.
   
Comments
antaresinsomnious 19-Oct-16 6:15am
   
I have been using the XmlReader Class.
It's completely not well formed at all. It was put out by Frontier Development for Elite Dangerous (It's their keybindings). I am afraid I will have to hard-code everything and I really don't want to do that because it just makes everything else harder in the end since I would have to change my xml file I am using any time I change my key bindings.
I haven't given up though.
Richard MacCutchan 19-Oct-16 6:45am
   
You may need to talk to the people who produce the data. XML has a well known structure and set of rules, but if people don't follow them then there is not much that you can do with the standard classes.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100