Well it was a stupid error, I was working with visual studio and could not
make out the error, When I checked it in XML spy which said "xml file not
well formed".
It was a great help from your side.
Thanks a lot Abbas
Regards,
Harry
"Zafar Abbas" wrote:
[color=blue]
> The correct namespace declaration is:
>
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>
> note the small 'i' in the instance.
>
> "Harry_Crow" <HarryCrow@discussions.microsoft.com> wrote in message
> news:89AC5640-91EE-4E47-90B4-63996D6BBD75@microsoft.com...[color=green]
> > nope not entering the while loop yet.
> > could you please tell me what the follwing error means
> >
> > The 'http://www.w3.org/2001/XMLSchema-Instance:noNamespaceSchemaLocation'
> > attribute is not declared.
> >
> > I have specified the rootnode of PDD.xml as below.
> > <PDD xmlns:xsi="http://www.w3.org/2001/XMLSchema-Instance"
> > xsi:noNamespaceSchemaLocation="PDDSch.xsd">
> >
> > Is it the problem that it is not able to link to PDDSch.xsd file.
> >
> > what it means by "attribute not declared"
> >
> > Thank you,
> > Harry
> >
> >
> > "Zafar Abbas" wrote:
> >[color=darkred]
> > > Associate a context to your XPathExpression and pass a NamespaceManager
> > > which has the namespace
http://tempuri.org/PDDSch.xsd mapped to a prefix
> > > which you then should use in your query. The method you should use:
> > >
> > > exp.SetContext ( NamespaceManager);
> > >
> > > "Harry_Crow" <HarryCrow@discussions.microsoft.com> wrote in message
> > > news:AFE794FE-0E99-48FE-8824-0A0642D3C53A@microsoft.com...
> > > > This is the Code:
> > > >
> > > > I have not assigned any namespaceManager or ParserContext for the[/color][/color]
> rootNode[color=green][color=darkred]
> > > >
> > > > XmlDocument doc = new XmlDocument();
> > > > doc.Load("PDD.xml");
> > > > XmlNode rootNode = doc.DocumentElement;
> > > > XPathNavigator nav = rootNode.CreateNavigator();
> > > > XPathExpression exp = nav.Compile("//PD/*"); //PD is the child node[/color][/color]
> of[color=green][color=darkred]
> > > PDD
> > > > XPathNodeIterator it = (XPathNodeIterator) nav.Evaluate(exp);
> > > >
> > > > while(iterator.MoveNext())
> > > > {
> > > >
> > > > }
> > > >
> > > > not entering the while loop itself.
> > > >
> > > > Regards,
> > > > Harry
> > > >
> > > >
> > > >
> > > > "Zafar Abbas" wrote:
> > > >
> > > > > Could you share the code and the data that you are using. You should[/color][/color]
> be[color=green][color=darkred]
> > > able
> > > > > to walk the child nodes in both cases.
> > > > >
> > > > >
> > > > > "Harry_Crow" <HarryCrow@discussions.microsoft.com> wrote in message
> > > > > news:B1023E7F-A7D3-4787-A2A0-8D83AFBE4B66@microsoft.com...
> > > > > > I have a schema file PDDSch.xsd which validates the PDD.xml file.[/color][/color]
> the[color=green][color=darkred]
> > > > > > rootnodes are as shown below
> > > > > >
> > > > > > PDD.xml
> > > > > > <PDD xmlns="http://tempuri.org/PDDSch.xsd"
> > > > > xmlns:xsi="http://www.w3.org/2001/XMLSchema-Instance" >
> > > > > >
> > > > > > PDDSch.xsd
> > > > > > <xs:schema id="PDD"
> > > > > > targetNamespace="http://tempuri.org/PDDSch.xsd"
> > > > > > xmlns="http://tempuri.org/PDDSch.xsd"
> > > > > > xmlns:mstns="http://tempuri.org/PDDSch.xsd"
> > > > > xmlns:xs="http://www.w3.org/2001/XMLSchema"
> > > > > > xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
> > > > > > attributeFormDefault="qualified"
> > > > > > elementFormDefault="qualified">
> > > > > >
> > > > > > now with the above mentioned namespaces and other attributes the
> > > > > validation
> > > > > > works properly. But I'm not able to read the child nodes through
> > > > > > XPathNavigator and XPathNodeIterator.
> > > > > >
> > > > > > If the above rootnodes changed as shown below.
> > > > > >
> > > > > > PDD.xml
> > > > > > <PDD xmlns:xsi="http://www.w3.org/2001/XMLSchema-Instance"
> > > > > > xsi:noNamespaceSchemaLocation="PDDSch.xsd">
> > > > > >
> > > > > > PDDSch.xsd
> > > > > > <xs:schema id="PDD"
> > > > > > xmlns:mstns="http://tempuri.org/PDDSch.xsd"
> > > > > xmlns:xs="http://www.w3.org/2001/XMLSchema"
> > > > > > xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
> > > > > > attributeFormDefault="qualified"
> > > > > > elementFormDefault="qualified">
> > > > > >
> > > > > > With the above rootnode attributes theXPathNavigator and
> > > XPathNodeIterator
> > > > > > will read the child nodes. but the validation is not correct.
> > > > > >
> > > > > > Could someone tell me What is the mistake I'm making here.
> > > > > >
> > > > > > Thanks and regards,
> > > > > > Harry
> > > > > >
> > > > >
> > > > >
> > > > >
> > >
> > >
> > >[/color][/color]
>
>
>[/color]