Home
The Toolkit for Online Communities
17127 Community Members, 0 members online, 1949 visitors today
Log In Register
OpenACS Home : Forums : OpenACS Q&A : what is the best practive for extracting xml like info from variables : One Message

Forum OpenACS Q&A: Re: what is the best practive for extracting xml like info from variables

the data can easily be modeled in the relational database. and that's how I had had it. But, if I do this it requires a number of extra trips to the database. If I could parse this I could reduce the number of trips to and from the DB to 3 - with a separate trip to the DB to get these variables it will require up to 15 trips for displaying just one page (which will substantially slow things down compared to the 3 trips). the thing is that most attributes only have one variable. or value, so my query has only the attribute_id and the value returned. For example, in my contacts database, if it asks what gender you are it returns either male of female. However, things like addresses are more complex, and  have multiple fields. thus if i get all the answers in a query where one column stays the attribute_id and the other the value i won't work for those - multi-value attributes... i don't know if this is making any sense to any of you ... i think i'll dicuss this in detail with the people i will be developing this contacts app with - it would take too explain the exact reasoning... other than to say that to make it work would improve performance substantially. I’ll take a look at ns_xml and tDom - i haven't used it yet and guess i should learn about them. I figured my regexp would work.

So I’ll take Alfred's suggestion: does anybody know of the correct this regexp?

The only reason I would see to use XML is if you need to store multiple addresses per 'record', in a nested format, or if you are gonna further pass that data outside to some other machine that wants XML data.

Here's what I mean:

<contact>

<home>
<address>
<street>1 Main St</street>
<city>Plainville</city>
<state>New York (or NY)</state>
</address>
<phone>
<number>123-4567</number>
<type>mobile</type>
</phone>
</home>

<work>
<address>
<street>1 Main St</street>
<city>Plainville</city>
<state>New York (or NY)</state>
</address>
<phone>
<number>123-4567</number>
<type>mobile</type>
</phone>
</work>

</contact>

I'm ignoring that tags don't need to balance in XML, (e.g. <number/>123-4567 could be valid )..

If it's nesting, the regex won't help with balanced tags or not, because you'll have two that match <street>xxx</street> or <street/> .. You really need to parse the tree, which is what ns_xml and similar tools are designed to do.