Oh, ok.

Using your example from below then, the tree would look something like this:

<Register>
/ | \
/ | \
/ | \
/ | \
<Purchase> <Purchase> <Purchase>
/ | \ / | \ / | \
<Buyer> <Item> <Description> <Buyer> <Item> <Description> <Buyer> <Item> <Description>



Note: use a fixed-width font such as Courier or Monaco to view the above tree "graphic", and please excuse the roughness of the image ;-)


"Register" is the root of the XML tree. "Purchase" nodes are siblings of each other, and children of the "Register" node. Similarly, "Buyer", "Item" and "Description", within a single "Purchase" node, are siblings of each other, and children of the parent "Purchase" node.

The XML functions you need are as follows:

Use revXMLRootNode to get the root "Register" node of the tree.

Use revXMLFirstChild to get the first child node of any particular node. In the case of the root "Register" node, that would be the first "Purchase" node. In the case of any particular "Purchase" node, it would be a "Buyer", "Item", or "Description" node (I do not think you are guaranteed the order in which siblings will be placed within the tree, so best to assume they could come in any order).

Use revXMLNextSibling to get the next sibling of a node. So for a "Purchase" node, this would give you another "Purchase" node. For a "Buyer", "Item" or "Description" node, this would give you one of the other two.


Within a node, use revXMLAttribute or revXMLAttributes to retrieve one or more attributes of the node, and use revXMLNodeContents to retrieve the contents of the node (the text between tags).


When you are finished with an XML tree, don't forget to free up the memory it uses by calling revDeleteXMLTree!


On Dec 13, 2004, at 8:36 PM, Bill Marriott wrote:

"Frank D. Engel, Jr." <[EMAIL PROTECTED]> writes:

I would suggest creating a new tag and use it to encase all of the
orders; something like this:

...

Do that for each of the registers, then use Rev's XML library to parse
it all together and to navigate the resulting XML trees, rather than
trying to pull each of them individually out of the text.

I want to generate a file that looks like it was generated from a single register, with the order numbers in sequential order (renumbering them as necessary). And the "use Rev's XML Library to parse it all together..." is the part I'm seeking assistance with. I basically want to grab a whole section of Purchases based on the Order attribute and move them into a new tree. Bob and the grocery store don't exist, it's just an illustration.


Truth be told I could probably have written a plain old fashioned text parsing utility to do this but I wanted to do it the "right way" using the XML library.

Here's some examples of my frustration:

Let's look at the XML again:

<?xml version="1.0"?>
<Register Station="A">
<Purchase Date="12/13/2004" Time="14:26:03" DateTime="20041213142603" Order="1">
<Buyer CustomerID="1234" />
<Item UPC="04905004" Price="0.40"/>
<Description>Cherry Coca-Cola</Description>
</Purchase>
<Purchase Date="12/13/2004" Time="14:26:14" DateTime="20041213142614" Order="1">
<Buyer CustomerID="1234" />
<Item UPC="03424005" Price="0.65"/>
<Description>Hershey's Chocolate Bar</Description>
</Purchase>
<Purchase Date="12/13/2004" Time="15:09:25" DateTime="20041213150925" Order="2">
<Buyer CustomerID="4567" />
<Item UPC="02880125" Price="6.95"/>
<Description>Marlboro Cigarettes</Description>
</Purchase>
</Register>


Suppose I load this into a Rev tree and it gets the ID 5280.

put revXMLNodeContents(5280,"Register/Purchase/Description")

yields "Cherry Coca-Cola" which is the first purchase. Now, what do I use to get the second one?

put revXMLChildContents(5280,"Register",tab,return,true,-1)

yields

Purchase[1]
Buyer[1]
Item[1]
Description[1] Cherry Coca-Cola
Purchase[2]
Buyer[1]
Item[1]
Description[1] Hershey's Chocolate Bar
Purchase[3]
Buyer[1]
Item[1]
Description[1] Marlboro Cigarettes

That's a good list of all the nodes, but I would still have to parse through it to build a table I could sort.

revXMLMatchingNode(5280,"Register","Purchase","Order",2,-1)

tells me,

/Register/Purchase[3]

which i could use in the command,

revXMLText(5280,"/Register/Purchase[3]")

to grab the whole of the third Purchase... but I cannot then say,

put revXMLMatchingNode(5280,"Register","Purchase","Order",1,-1)

and get a list of all the purchases related to Order #1. It yields only the first one. So how do I find the second and subsequent ones?

Thanks,
- Bill
_______________________________________________
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution


-----------------------------------------------------------
Frank D. Engel, Jr.  <[EMAIL PROTECTED]>

$ ln -s /usr/share/kjvbible /usr/manual
$ true | cat /usr/manual | grep "John 3:16"
John 3:16 For God so loved the world, that he gave his only begotten Son, that whosoever believeth in him should not perish, but have everlasting life.
$
_______________________________________________
use-revolution mailing list
[EMAIL PROTECTED]
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to