It occurs when I make an xpath query using the id() operator, but it doesn't
occur everytime. It can take several other queries on this document before it
occurs.
Here are the details:
Exception:
System.NullReferenceException {"Object reference not set to an instance of
an object."}
Source :
System.Xml
StackTrace :
at System.Xml.XmlDocument.GetElementById(String elementId)
at System.Xml.DocumentXPathNavigator.MoveToId(String id)
at MS.Internal.Xml.XPath.IDQuery.ProcessIds(String val)
at MS.Internal.Xml.XPath.IDQuery.advance()
at MS.Internal.Xml.XPath.XPathSelectionIterator.MoveN ext()
at MS.Internal.Xml.XPath.XPathNodeList.ReadUntil(Int3 2 index)
at MS.Internal.Xml.XPath.XmlNodeListEnumerator.MoveNe xt()
The code executed when it occured: (the debugger points the "in", so it
happens in SelectNodes() )
string xPath = "id('230b2b34-8eb4-408e-a817-4c055525bafa')";
foreach(XmlNode n in _Document.SelectNodes(xPath))
{
...
}
The xml document:
<!DOCTYPE USS[
<!ELEMENT USS (Entity*)>
<!ELEMENT Entity (Reference*, Attribute*)>
<!ELEMENT Reference EMPTY>
<!ELEMENT Attribute (#PCDATA)>
<!ATTLIST Entity
Type CDATA #REQUIRED
Id ID #REQUIRED
<!ATTLIST Reference
Role CDATA #REQUIRED
RefId IDREF #REQUIRED
<!ATTLIST Attribute
Type CDATA #REQUIRED
Name CDATA #REQUIRED
]>
<USS>
<Entity Type="EPT:Priority" Id="b55b67a9-a941-4a25-bea0-22c5dd2ccebf">
<Attribute Name="Name" Type="System.String">3 - Urgent</Attribute>
</Entity>
<Entity Type="EPT:State" Id="b96d364d-aa9d-4dc3-a468-78d66ac050d9">
<Attribute Name="Description" Type="System.String">The case is new and
active</Attribute>
<Attribute Name="Name" Type="System.String">Opened</Attribute>
<Attribute Name="ClosesCase" Type="System.Boolean">False</Attribute>
</Entity>
<Entity Type="EPT:Priority" Id="51b3d245-cd32-4396-8553-18f77398d666">
<Attribute Name="Name" Type="System.String">If Time</Attribute>
</Entity>
<Entity Type="EPT:Category" Id="1a672d3a-a8d2-49b6-9de6-52ff69b275fb">
<Attribute Name="Name" Type="System.String">Request</Attribute>
<Attribute Name="Bitmap"
Type="System.String">~/images/app/email.gif</Attribute>
</Entity>
<Entity Type="EPT:Priority" Id="fb04e846-d592-4650-bb24-4ea905c8d8ce">
<Attribute Name="Name" Type="System.String">1 - Urgent</Attribute>
</Entity>
<Entity Type="EPT:State" Id="b8ad8d84-c580-49fc-9ea1-6c3a8e85141e">
<Attribute Name="ClosesCase" Type="System.Boolean">True</Attribute>
<Attribute Name="Description" Type="System.String">The case had no sense
and is no more active</Attribute>
<Attribute Name="Name" Type="System.String">Closed</Attribute>
</Entity>
<Entity Type="EPT:Priority" Id="e23411d3-fc09-4ded-b6f1-95e22f7a0915">
<Attribute Name="Name" Type="System.String">2 - Urgent</Attribute>
</Entity>
<Entity Type="EPT:State" Id="c62bbb33-1d43-4a5a-ad4d-8aabf16bf205">
<Attribute Name="Name" Type="System.String">Resolved</Attribute>
<Attribute Name="ClosesCase" Type="System.Boolean">True</Attribute>
<Attribute Name="Description" Type="System.String">The case was
solved</Attribute>
</Entity>
<Entity Type="EPT:Project" Id="adf6b7d7-96ef-4418-8028-5b7d7bbbc758">
<Attribute Name="Name" Type="System.String">EUSS</Attribute>
<Reference Role="Cases" RefId="230b2b34-8eb4-408e-a817-4c055525bafa" />
<Reference Role="Cases" RefId="230b2b34-8eb4-408e-a817-4c055525bafa" />
<Reference Role="Cases" RefId="230b2b34-8eb4-408e-a817-4c055525bafa" />
</Entity>
<Entity Type="EPT:Priority" Id="8743a910-aff9-4589-aab9-e849d68b90f6">
<Attribute Name="Name" Type="System.String">Undefined</Attribute>
</Entity>
<Entity Type="EPT:Category" Id="166d7c81-b924-4022-83d3-829b6abbaf92">
<Attribute Name="Bitmap"
Type="System.String">~/images/app/feature.gif</Attribute>
<Attribute Name="Name" Type="System.String">Feature</Attribute>
</Entity>
<Entity Type="EPT:Project" Id="243200bf-953f-4d25-a76e-644ac4ccd43f">
<Attribute Name="Name" Type="System.String">Project Tracker</Attribute>
</Entity>
<Entity Type="EPT:Category" Id="b5b5b603-9ca2-42a6-976e-8b1982f80ab6">
<Attribute Name="Name" Type="System.String">Bug</Attribute>
<Attribute Name="Bitmap"
Type="System.String">~/images/app/bug.gif</Attribute>
</Entity>
<Entity Type="EPT:Priority" Id="6d127939-1b5b-4fe6-98e0-02ae6ea6bf57">
<Attribute Name="Name" Type="System.String">Useless</Attribute>
</Entity>
<Entity Type="EPT:Case" Id="230b2b34-8eb4-408e-a817-4c055525bafa">
<Attribute Name="Creation" Type="System.DateTime">4/27/2005 7:53:47
PM</Attribute>
<Attribute Name="Opened" Type="System.Boolean">True</Attribute>
<Attribute Name="Description" Type="System.String">
</Attribute>
<Attribute Name="End" Type="System.DateTime">4/27/2005 12:00:00
AM</Attribute>
<Attribute Name="Category" Type="System.String">Feature</Attribute>
<Attribute Name="Name" Type="System.String">New Case</Attribute>
<Attribute Name="State" Type="System.String">Opened</Attribute>
<Attribute Name="Priority" Type="System.String">Undefined</Attribute>
</Entity>
</USS>
Thank you