I have the following code:

Code:
        Dim X As XElement = _
     <ModelVisual3D x:Name="World" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">
         <ModelVisual3D x:Name="AmbientLightContainer">
             <ModelVisual3D.Content>
                 <AmbientLight x:Name="AmbientLight" Color="#FF7F7F7F"/>
             </ModelVisual3D.Content>
         </ModelVisual3D>
         <ModelVisual3D x:Name="DirectionalLightContainer">
             <ModelVisual3D.Content>
                 <DirectionalLight x:Name="DirectionalLight" Color="#FF3F3F3F" Direction="0,0,-1">
                     <DirectionalLight.Transform>
                         <TranslateTransform3D OffsetX="0" OffsetY="0" OffsetZ="3"/>
                     </DirectionalLight.Transform>
                 </DirectionalLight>
             </ModelVisual3D.Content>
         </ModelVisual3D>
         <ModelVisual3D x:Name="DefaultGroup">
             <ModelVisual3D.Content>
                 <GeometryModel3D x:Name="Sphere" d:Bounds="-0.951057970523834,-1,-1,1.90211594104767,2,2">
                     <GeometryModel3D.Geometry>
                         <MeshGeometry3D Positions="0.262869,-0.525738,0.809012 0.42532301,-0.85065401,0.30901101 0.72359997,-0.44721499,0.52572 -0.16245601,-0.85065401,0.49999499 -0.27638501,-0.44721499,0.85064 0,-1,0 0.85064799,-0.52573597,0 0.42532301,-0.85065401,-0.30901101 0.72359997,-0.44721499,-0.52572 -0.68818903,-0.52573597,0.49999699 -0.52573001,-0.85065198,0 -0.89442497,-0.44721499,0 -0.68818903,-0.52573597,-0.49999699
-0.16245601,-0.85065401,-0.49999499 -0.27638501,-0.44721499,-0.85064 0.262869,-0.525738,-0.809012 0.95105797,0,0.30901301 0.95105797,0,-0.30901301 0.89442497,0.44721499,0 0,0,1 0.58778602,0,0.809017 0.27638501,0.44721499,0.85064 -0.95105797,0,0.30901301 -0.58778602,0,0.809017 -0.72359997,0.44721499,0.52572 -0.58778602,0,-0.809017
-0.95105797,0,-0.30901301 -0.72359997,0.44721499,-0.52572 0.58778602,0,-0.809017 0,0,-1 0.27638501,0.44721499,-0.85064 0.68818903,0.52573597,0.49999699 -0.262869,0.525738,0.809012 -0.85064799,0.52573597,0 -0.262869,0.525738,-0.809012 0.68818903,0.52573597,-0.49999699 0.16245601,0.85065401,0.49999499 0.52573001,0.85065198,0 0,1,0
-0.42532301,0.85065401,0.30901101 -0.42532301,0.85065401,-0.30901101 0.16245601,0.85065401,-0.49999499" TextureCoordinates="0.58466866,0.67621067 0.63983953,0.82379382 0.75751731,0.64758573 0.44805842,0.82379395 0.41086252,0.64758584 0.5,1 0.82379002,0.67620998 0.63983953,0.82379382 0.75751731,0.64758573 0.25840589,0.67621007 0.3237923,0.8237923 0.14758433,0.64758433 0.25840589,0.67621007 0.44805842,0.82379395 0.41086252,0.64758584 0.58466866,0.67621067 0.90000135,0.5 0.90000135,0.5 0.85241567,0.35241567 0.5,0.5 0.7000002,0.5 0.58913748,0.35241416 0.09999865,0.5
0.2999998,0.5 0.24248269,0.35241427 0.2999998,0.5 0.09999865,0.5 0.24248269,0.35241427 0.7000002,0.5 0.5,0.5 0.58913748,0.35241416 0.74159411,0.32378993 0.41533134,0.32378933 0.17620998,0.32379002 0.41533134,0.32378933 0.74159411,0.32378993 0.55194158,0.17620605 0.6762077,0.1762077 0.5,0 0.36016047,0.17620618 0.36016047,0.17620618 0.55194158,0.17620605" TriangleIndices="0 1 2 1 0 3 4 3 0 3 5 1 6 2 1 1 7 6 8 6 7 1 5 7 9 3 4 3 9 10 11 10 9 10 5 3 12 10 11 10 12 13 14 13 12 13 5 10 15 13 14 13 15 7 8 7 15 7 5 13 16 2 6 6 17 16 18 16 17 17 6 8 19 4 0 0 20 19 21 19 20 20 0 2 22 11 9 9 23 22 24 22 23 23 9 4 25 14 12 12 26 25 27 25 26 26 12 11 28 8 15 15 29 28 30 28 29 29 15 14 31 16 18 16 31 20 21 20 31 20 2 16 32 19 21 19 32 23 24 23 32 23 4 19 33 22 24 22 33 26 27 26 33 26 11 22 34 25 27 25 34 29 30 29 34 29 14 25 35 28 30 28 35 17 18 17 35 17 8 28 36 21 31 31 37 36 38 36 37 37 31 18 39 24 32 32 36 39 38 39 36 36 32 21 40 27 33 33 39 40 38 40 39 39 33 24 41 30 34 34 40 41 38 41 40 40 34 27 37 18 35 35 41 37 38 37 41 41 35 30"/>
                     </GeometryModel3D.Geometry>
                     <GeometryModel3D.Material>
                         <DiffuseMaterial Brush="#FFFFFFFF"/>
                     </GeometryModel3D.Material>
                 </GeometryModel3D>
             </ModelVisual3D.Content>
             <ModelVisual3D.Transform>
                 <Transform3DGroup>
                     <TranslateTransform3D OffsetX="0" OffsetY="0" OffsetZ="0"/>
                     <ScaleTransform3D ScaleX="1" ScaleY="1" ScaleZ="1"/>
                     <RotateTransform3D d:EulerAngles="0,0,0"/>
                 </Transform3DGroup>
             </ModelVisual3D.Transform>
         </ModelVisual3D>
     </ModelVisual3D>

        Dim XPath As String

        XPath = "//ModelVisual3D/ModelVisual3D/ModelVisual3D.Transform/Transform3DGroup/TranslateTransform3D"

        X.XPathSelectElement(XPath).SetAttributeValue("OffsetX", "5")
I keep getting the following error:

Code:
Object reference not set to an instance of an object.
I believe theres an error in the XPath string but I cant figure out where.

Any help is appreciated. Thanks

Q