forum.vdsworld.com Forum Index forum.vdsworld.com
Visit VDSWORLD.com
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


XMLDOC bug?

 
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help
View previous topic :: View next topic  
Author Message
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Sun Mar 14, 2010 7:47 pm    Post subject: XMLDOC bug? Reply with quote

Hi there!

I'm just checking out the XML capabilities of VDS6. I think there might be a bug in the SEEK function.
Consider this XML file:

Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<hom>
  <node1 attrib="test">
    <subnode>contents1</subnode>
  </node1>
</hom>
<hom>
  <node2 attrib="testx">
    <subnode>contents2x</subnode>
  </node2>
</hom>
<hom>
  <node2 attrib="test">
    <subnode>contents2</subnode>
  </node2>
</hom>
<hom>
  <node3 attrib="test">
    <subnode>contents3</subnode>
  </node3>
</hom>


..and run it through this script:

Code:
XMLDOC create,1
XMLDOC loadfile,1,debug.xml

if @XMLDOC(SEEK,1,/hom/node2["@attrib"=test])
  info @XMLDOC(VALUE,1,subnode)
end


In my view the script should look for the node named node2 and then return the contents of its subnode -
result should be contents2 but it is contents1

The function seems to match the first node having the right attribute even if the node name does not match the seek
criteria.

Am I getting something wrong here?

Greetz
Dread

_________________
~~ Alcohol and calculus don't mix... Don't drink and derive! ~~

String.DLL * advanced string processing
Back to top
View user's profile Send private message
Aslan
Valued Contributor
Valued Contributor


Joined: 31 May 2001
Posts: 589
Location: Memphis, TN USA

PostPosted: Tue Mar 16, 2010 3:06 am    Post subject: Reply with quote

I don't think VDS understands ["@attrib"=test]

I wonder if it would work with

Code:
if @XMLDOC(SEEK,1,/hom/node2 attrib="test")
  info @XMLDOC(VALUE,1,subnode)
end

-OR-
Code:
if @XMLDOC(SEEK,1,/hom/"node2 attrib=test")
  info @XMLDOC(VALUE,1,subnode)
end


Or VDS only understands very basic XML

e.g
Code:
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
Back to top
View user's profile Send private message Send e-mail
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Tue Mar 16, 2010 12:04 pm    Post subject: Reply with quote

["@attrib"=test] is actually documented in the help file, and it does in fact work if only one XML entity has
the attribute being searched.

The problem arises when two or more nodes have the same attribute. Then VDS will pick the first node having the
correct attribute even though the actual node name does not match at all...

Greetz
Dread

_________________
~~ Alcohol and calculus don't mix... Don't drink and derive! ~~

String.DLL * advanced string processing
Back to top
View user's profile Send private message
Aslan
Valued Contributor
Valued Contributor


Joined: 31 May 2001
Posts: 589
Location: Memphis, TN USA

PostPosted: Wed Mar 17, 2010 11:39 pm    Post subject: Reply with quote

I tried even using none similar words for the attribute values but it didn't seem to make a difference.

It seems to only work if the attribute is numeric.

Code:
<hom>
  <node1 attrib="1">
    <subnode>contents1</subnode>
  </node1>
  <node2 attrib="1">
    <subnode>contents2x</subnode>
  </node2>
  <node2 attrib="2">
    <subnode>contents2</subnode>
  </node2>
  <node3 attrib="1">
    <subnode>contents3</subnode>
  </node3>
</hom>



Code:
XMLDOC create,1
XMLDOC loadfile,1,debug.xml

if @XMLDOC(SEEK,1,/hom/node2["@attrib=2"])
  info @XMLDOC(VALUE,1,subnode)
end
exit
Back to top
View user's profile Send private message Send e-mail
Aslan
Valued Contributor
Valued Contributor


Joined: 31 May 2001
Posts: 589
Location: Memphis, TN USA

PostPosted: Thu Mar 18, 2010 12:07 am    Post subject: Reply with quote

Ignore my last post.

To further confuse things; this works

Debug.xml
Code:
<Root>
 <Node1 ID="TestA">
  <SubNode1>Value11</SubNode1>
  <SubNode2>Value12</SubNode2>
  <SubNode3>Value13</SubNode3>
 </Node1>
 <Node2 ID="TestA">
  <SubNode1>Value21</SubNode1>
  <SubNode2>Value22</SubNode2>
  <SubNode3>Value23</SubNode3>
 </Node2>
 <Node2 ID="TestB">
  <SubNode1>Value31</SubNode1>
  <SubNode2>Value32</SubNode2>
  <SubNode3>Value33</SubNode3>
 </Node2>
 <Node ID="TestA">
  <SubNode1>Value41</SubNode1>
  <SubNode2>Value42</SubNode2>
  <SubNode3>Value43</SubNode3>
 </Node>
</Root>


Code:
XMLDOC create,1
XMLDOC loadfile,1,debug.xml

if @XMLDOC(SEEK,1,/root/node2["@ID=TestB"])
  info @XMLDOC(VALUE,1,subnode3)
end
Back to top
View user's profile Send private message Send e-mail
Dr. Dread
Professional Member
Professional Member


Joined: 03 Aug 2001
Posts: 1065
Location: Copenhagen, Denmark

PostPosted: Fri Mar 19, 2010 9:00 am    Post subject: Reply with quote

Yeah, the behaviour is erratic.

If you do this
Code:
if @XMLDOC(SEEK,1,/root/node["@ID=TestB"])
  info @XMLDOC(VALUE,1,subnode3)
end

VDS will return the same string - and it shouldn't

Well, I guess I have to look to Delphi - a shame when VDS has a nice XML feature Confused

Greetz
Dread

_________________
~~ Alcohol and calculus don't mix... Don't drink and derive! ~~

String.DLL * advanced string processing
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forum.vdsworld.com Forum Index -> General Help All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum

Twitter@vdsworld       RSS

Powered by phpBB © 2001, 2005 phpBB Group