Click to See Complete Forum and Search --> : XML Related


nadz
July 3rd, 2006, 07:13 AM
Hey guys,
Problem stated as:
I have an XML doc
I know how to access the nodes and get the values e.g.
by doing so I get the values for all title nodes.

XmlDocument* doc = new XmlDocument();
doc->Load("c:\\abc.xml");
XPathNavigator* nav = doc->CreateNavigator();
nav->MoveToRoot();
XPathNodeIterator* PixNode = nav->Select("/MetaInfo/File/Title");
while (PixNode->MoveNext())
{
String* num = PixNode->Current->get_Value();
System::Windows::Forms::MessageBox::Show(num);
}

by doing this I get all the values of file nodes

XmlDocument* doc = new XmlDocument();
doc->Load("c:\\abc.xml");
XPathNavigator* nav = doc->CreateNavigator();
nav->MoveToRoot();
XPathNodeIterator* PixNode = nav->Select("/MetaInfo/File");
while (PixNode->MoveNext())
{
String* num = PixNode->Current->get_Value();
System::Windows::Forms::MessageBox::Show(num);
}

but what I want is that I can get a particular files title value.
the sql query would be

select title from first
where filename = "xyz";

help me if anyone has idea plz.

Or it can't be done without transforming XML to sqlType
Thanking you
nadz

cilu
July 3rd, 2006, 09:25 AM
Try this:

XPathNodeIterator* PixNode = nav->Select("/MetaInfo/File/[Title='xyz']");

Do you want an exact match or a partial match (such as with the LIKE clause)?

cilu
July 3rd, 2006, 09:26 AM
BTW, here is a good introductory tutorial on XPath (http://www.w3schools.com/xpath/).

nadz
July 6th, 2006, 11:18 AM
Thanks cilu
that helped
cheers