Re: Navigating through added XML data?

2006-03-30 Thread Ken Ray
On 3/30/06 4:36 PM, "Mark Wieder" <[EMAIL PROTECTED]> wrote:

> John-
> 
> Thursday, March 30, 2006, 10:01:27 AM, you wrote:
> 
>> What was messing me up was I was looking at the text of an xml
>> file, and seeing it formatted correctly lead me to believe that the
>> XML was good. When I started dumping out the XML after I added a new
>> attribute and child nodes, I noticed I was not getting things right.
>> Essentially, not getting the paths correct in the XML file for the
>> new attribute and subsequent new child nodes.
> 
> Try opening the xml file in your web browser. You'll get an error if
> it can't parse the file properly, otherwise you should see the tree
> displayed as you expect it.

You could also download my XML Library and run it through the parser, it
would also let you know if the XML is not formatted properly...

  http://www.sonsothunder.com/products/xmllib/xmllib.htm

Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: [EMAIL PROTECTED]


___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Navigating through added XML data?

2006-03-30 Thread Mark Wieder
John-

Thursday, March 30, 2006, 10:01:27 AM, you wrote:

> What was messing me up was I was looking at the text of an xml
> file, and seeing it formatted correctly lead me to believe that the
> XML was good. When I started dumping out the XML after I added a new
> attribute and child nodes, I noticed I was not getting things right.
> Essentially, not getting the paths correct in the XML file for the
> new attribute and subsequent new child nodes.

Try opening the xml file in your web browser. You'll get an error if
it can't parse the file properly, otherwise you should see the tree
displayed as you expect it.

-- 
-Mark Wieder
 [EMAIL PROTECTED]

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Navigating through added XML data?

2006-03-30 Thread Ken Ray
On 3/30/06 12:01 PM, "John Patten" <[EMAIL PROTECTED]> wrote:

>   put revXMLNumberOfChildren(cd fld "XMLID","URL_Table",,-1) into
> numberOfNodes
>   put (numberOfNodes div 10)into theNewNode
>   add 1 to TheNewNode

Just curious, John... why did you need to divide the number of child nodes
by 10 and add 1 to get the new node number? Wouldn't it just be (the number
of children + 1) ?

> This seems to work correctly, however i do notice in the XML file the new
> attribute has all the content after it in addition to the nodes that have it
> individually. Not sure why it's doing that?

You mean all the child nodes have the same content? Can you provide an
example of what you're seeing?
 
Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: [EMAIL PROTECTED]

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Navigating through added XML data?

2006-03-30 Thread John Patten
Thanks Sarah and Peter!

Also Sarah's tutorial has been very helpful. I have never done anything with 
XML, or arrays for that matter, so it's still a lot of trial and error. It's 
kind of strange how you can stare at something for a couple hours, go away for 
a while, come back to it, and then BING, the solution just kind of jumps out at 
you.

What was messing me up was I was looking at the text of an xml file, and seeing 
it formatted correctly lead me to believe that the XML was good. When I started 
dumping out the XML after I added a new attribute and child nodes, I noticed I 
was not getting things right. Essentially, not getting the paths correct in the 
XML file for the new attribute and subsequent new child nodes.

Here is what finally worked for me:

 put cd fld "XMLID" into theTargetXML
  
  
  put revXMLNumberOfChildren(cd fld "XMLID","URL_Table",,-1) into numberOfNodes
  put (numberOfNodes div 10)into theNewNode
  add 1 to TheNewNode
  
  RevAddXMLNode theTargetXML,"URL_Table/","URL",""
  
  revSetXMLAttribute theTargetXML,"/URL_Table/URL"&"[" & theNewNode 
&"]","IDnum",theNewNode
  
  revAddXMLNode theTargetXML,"/URL_Table/URL" &"[" & theNewNode 
&"]","subject","Art"
  revAddXMLNode theTargetXML,"/URL_Table/URL" &"[" & theNewNode 
&"]","key_words","Fine Art"
  revAddXMLNode theTargetXML,"/URL_Table/URL" &"[" & theNewNode &"]","Grade","5"
  revAddXMLNode theTargetXML,"/URL_Table/URL" &"[" & theNewNode 
&"]","Standard","Creativity"
  revAddXMLNode theTargetXML,"/URL_Table/URL" &"[" & theNewNode 
&"]","Title","Art in the Classroom"
  revAddXMLNode theTargetXML,"/URL_Table/URL" &"[" & theNewNode 
&"]","Description","Will this work for Art"
  revAddXMLNode theTargetXML,"/URL_Table/URL" &"[" & theNewNode 
&"]","Submitted_by","John Art"
  revAddXMLNode theTargetXML,"/URL_Table/URL" &"[" & theNewNode 
&"]","emailAddress","[EMAIL PROTECTED]"
  revAddXMLNode theTargetXML,"/URL_Table/URL" &"[" & theNewNode 
&"]","school","Orchard School"


This seems to work correctly, however i do notice in the XML file the new 
attribute has all the content after it in addition to the nodes that have it 
individually. Not sure why it's doing that?

However, navigating through the attributes and associated nodes is not a big 
deal because I'm only using the first part of the attribute (i.e.1,2, 3..) when 
determining which group of nodes to display.

I'm sure there there are a lot more sophisticated ways to do what I'm trying to 
do, but at least I continue to be successful! :-)


Thank you!

John Patten
SUSD





-

Message: 23 
Date: Thu, 30 Mar 2006 13:26:33 +1000 
From: "Sarah Reichelt" <[EMAIL PROTECTED]> 
Subject: Re: Navigating through added XML data? 
To: "How to use Revolution"  
Message-ID: 
<[EMAIL PROTECTED]> 
Content-Type: text/plain; charset=ISO-8859-1 

> I'm trying to learn to use XML to store stack data. I've managed to load an 
> existing XML document into the stack, navigate through XML data using 
> revXMLMatchingNode and revXMLChildContents and placing contents in specific 
> flds, and creating additonal data using revSetXMLAttribute and revAddXMLNode. 
> 
> So far so good. However, ultimatley I want to be able to continue navigating 
> through the XML data including any new data that has been entered. 
> 
> I can see that the additional data has been added by using 
> revXMLChildContents, however I don't know how to save the results of 
> revXMLChildContents back into the stack as a XML file, and thus enabling 
> navigation through the appended XML file. 

___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Navigating through added XML data?

2006-03-29 Thread Sarah Reichelt
> I'm trying to learn to use XML to store stack data. I've managed to load an 
> existing XML document into the stack, navigate through XML data using 
> revXMLMatchingNode and revXMLChildContents and placing contents in specific 
> flds, and creating additonal data using revSetXMLAttribute and revAddXMLNode.
>
> So far so good. However, ultimatley I want to be able to continue navigating 
> through the XML data including any new data that has been entered.
>
> I can see that the additional data has been added by using 
> revXMLChildContents, however I don't know how to save the results of 
> revXMLChildContents back into the stack as a XML file, and thus enabling 
> navigation through the appended XML file.
>
> I had been trying to do it using  revCreateXMLTree but it errors because 
> revXMLChildContents does not return a proper XML format.


An XML file is just plain text with tag markers. When you read it into
Rev and call revCreateXMLTree or use revCreateXMLTreeFromFile, this
creates an internal data structure - the XML tree.

You can edit the tree using the revAddXMLNode, revSetXMLAttribute etc
functions and the internal data tree is updated every time. However
your original disk file will not be changed unless you manually save
the text form of the XML data to it.

To do this, you need to use revXMLText(treeID). This gives you plain
text, although it is not formatted neatly. To get a slightly
better-looking display, use this:  revXMLText(treeID,,true)
Yes, there are 2 commas there. The second parameter can be used to
specify the starting node if you don't want to convert all the tree to
text. The third parameter is undocumented, but if "true", it does some
formatting of the text.

Once you have the text, you can save it to a text file using the
normal URL commands.

For further information, you may be interested in my XML tutorial at


Cheers,
Sarah
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Re: Navigating through added XML data?

2006-03-29 Thread Peter T. Evensen
If you have an XML Tree, you can add nodes using revAddXMLNode, put data 
into the node using revPutIntoXMLNode and then use revXMLText(tXMLTree) to 
save the text to a file name.


Here is a function I created to add data to an arbitrary node in an 
existing tree (it creates all the nodes, if they do not exist, but assumes 
the root node exists):


on SaveToXMLTree TreeID, Path, Data
  if TreeID is a number then
-- see if the node exists
set the itemDelimiter to "/"
repeat with i = 2 to the number of items in Path - 1
  put item 1 to i of Path into startNode
  put item i+1 of Path into node
  if revXMLChildNames(TreeID,startNode,"",node,false) is empty then
revAddXMLNode TreeID, startNode, node, ""
if the result contains "xmlerr" then
  ReportError "Error adding node" && item 1 to i+1 of Path && "to 
XML Tree:" && the result

end if
  end if
end repeat
set the itemDelimiter to ","
if the platform is "MacOS" then
  put the MacToISO of Data into Data
end if
revPutIntoXMLNode TreeID,Path,Data
if the result contains "xmlerr" then
  ReportError "Error adding data to node" && Path && ":" && the result
end if
  end if
end SaveToXMLTree


At 05:59 PM 3/29/2006, you wrote:

Hello All...

I'm trying to learn to use XML to store stack data. I've managed to load 
an existing XML document into the stack, navigate through XML data using 
revXMLMatchingNode and revXMLChildContents and placing contents in 
specific flds, and creating additonal data using revSetXMLAttribute and 
revAddXMLNode.


So far so good. However, ultimatley I want to be able to continue 
navigating through the XML data including any new data that has been entered.


I can see that the additional data has been added by using 
revXMLChildContents, however I don't know how to save the results of 
revXMLChildContents back into the stack as a XML file, and thus enabling 
navigation through the appended XML file.


I had been trying to do it using  revCreateXMLTree but it errors because 
revXMLChildContents does not return a proper XML format.


Any suggestions?

Thank you!

John Patten
SUSD
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your 
subscription preferences:

http://lists.runrev.com/mailman/listinfo/use-revolution


Peter T. Evensen
http://www.PetersRoadToHealth.com
314-629-5248 or 888-628-4588 
___

use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution


Navigating through added XML data?

2006-03-29 Thread John Patten
Hello All...

I'm trying to learn to use XML to store stack data. I've managed to load an 
existing XML document into the stack, navigate through XML data using 
revXMLMatchingNode and revXMLChildContents and placing contents in specific 
flds, and creating additonal data using revSetXMLAttribute and revAddXMLNode.

So far so good. However, ultimatley I want to be able to continue navigating 
through the XML data including any new data that has been entered.

I can see that the additional data has been added by using revXMLChildContents, 
however I don't know how to save the results of revXMLChildContents back into 
the stack as a XML file, and thus enabling navigation through the appended XML 
file. 

I had been trying to do it using  revCreateXMLTree but it errors because 
revXMLChildContents does not return a proper XML format.

Any suggestions?

Thank you!

John Patten
SUSD
___
use-revolution mailing list
use-revolution@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution