From: Jimmy Z. <cra...@co...> - 2006-06-14 06:30:34
|
It can be done let me give an example.. The XML snippet is as follows: <test attr1=3D'val1' attr2 =3D 'val2' /> vn.getRootIndex() will get you the index value of "test" element, which = is=20 root.... say its index is 1; then next few tokens attr1 ---> index value is 2 val1 =3D=3D>index value is 3 attr2 ----> index is 4 val2 =3D=3D> index value is 5 make sure you check for the token type at the given index values using vn.getTokenType(int i).. possible token types are ATTR_VAL, ATTR_NAME, ATTR_NS (for namespace) >How can we find an attribute's value by number? >Like we have VTDNav.getAttrValue(String) >but that gives the value given the key. >What if i dont know the key? >Help!!!!!!!!!!!!!! |
From: Jimmy Z. <cra...@co...> - 2006-06-14 06:44:14
|
Yes, but vn.getCurrentIndex() will get you the index value of the cursor = element... ----- Original Message -----=20 From: Aakash Jain=20 To: Jimmy Zhang=20 Sent: Tuesday, June 13, 2006 11:36 PM Subject: Re: find attribute value by index getRootIndex() returns the inddex of the root element of the xml tree. eg: <root> <child attr1=3D"val1"/> <child attr1=3D"val2"/> </root> so, no matter where your context object is , it will always return = index for "root".=20 On 6/14/06, Jimmy Zhang <cra...@co...> wrote: It can be done let me give an example.. The XML snippet is as follows: <test attr1=3D'val1' attr2 =3D 'val2' /> vn.getRootIndex() will get you the index value of "test" element, = which is root....=20 say its index is 1; then next few tokens attr1 ---> index value is 2 val1 =3D=3D>index value is 3 attr2 ----> index is 4 val2 =3D=3D> index value is 5 make sure you check for the token type at the given index values=20 using vn.getTokenType(int i).. possible token types are ATTR_VAL, ATTR_NAME, ATTR_NS (for = namespace) >How can we find an attribute's value by number? >Like we have VTDNav.getAttrValue(String)=20 >but that gives the value given the key. >What if i dont know the key? >Help!!!!!!!!!!!!!! --=20 " There are 10 types of people in this world, those who understand = binary and others who don't. "=20 Aakash Jain PUCSD Ph : 91 9844223652 |
From: Jimmy Z. <cra...@co...> - 2006-06-14 06:50:26
|
Similar issues have been raised before, yes we are still thinking about = that...=20 original design goal is to keep as much complexity out of the = implementation as possible, the problem of=20 multiple context object is that once we give people more than one = cursor, people will want even more,=20 potentially making position tracking difficult ... the goal is KISS, = keep it simple and stupid... regarding LC entry, yes, there is a way, but requires hacking on your = side, also for nodes that goes beyond depth 4, linear scan is used to locate child nodes... so the best/simplest way is to wrap around vn.toElement(FIRST_CHILD).... it will take care of everything...=20 ----- Original Message -----=20 From: Aakash Jain=20 To: Jimmy Zhang=20 Sent: Tuesday, June 13, 2006 11:28 PM Subject: Re: multiple context objects In place of providing multiple context object, it can provide context = save and load methods. Currently it provides push and pop methods that = operate on VTD's stack only. But the user cannot save and load the = context in his defined stack or some other array.=20 Regarding the hasChild() problem: The lower 32 bits in LC entry contains -1 if there is no child of a = node. Is there a way to access that entry. Because this will be a = straight forward check to know if the node has child or not.=20 --=20 Aakash Jain PUCSD Ph : 91 9844223652=20 " There are 10 types of people in this world, those who understand = binary and others who don't. " On 6/14/06, Jimmy Zhang <cra...@co...> wrote: Sorry for the late reply... right now VTD-XML doesn't implement multiple context object, because = a context object is a global variable so you can use it across procedures... = and we have yet to come across a scenario where multiple context object is needed...=20 the best way to check whether a node has child or not is navigate to = it and check the result value... if (vn.toElement(VTDNav.FC) =3D=3D false) {// no child } else { vn.toElement (VTDNav.P); // return to the orginal node // has child... } let me know if there is any further question... |