Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Query XML data

I have created an XML file the contains basic application info, eg. App name,
app class, primary contact, secondary, and app sponser. I would now like
to create a way to query that file via a web interface.

For example enter the app name, click query, and generate results based on
the XML file. Anyone have any suggestions/examples on how to accomplish
this. I have been trying to use XML Spy and man am I confused.

I would also like to create a seperate web interface for adding records.

Thanks!!
[544 byte] By [JJ] at [2007-11-9 15:23:31]
# 1 Re: Query XML data
"JJ" <jjshea@sysmatrix.net> wrote:
>
>I have created an XML file the contains basic application info, eg. App
name,
>app class, primary contact, secondary, and app sponser. I would now like
>to create a way to query that file via a web interface.
>
>For example enter the app name, click query, and generate results based
on
>the XML file. Anyone have any suggestions/examples on how to accomplish
>this. I have been trying to use XML Spy and man am I confused.
>
>I would also like to create a seperate web interface for adding records.
>
>Thanks!!

The easiest way is to use "selectNodes" with an XPath query on the server
side. This will give you back just the parts of the document that you are
interested in.

Now you have a choice - you can do all of this programmatically, writing
code to parse the DOM nodes and formatting them into HTML, or you can use
parameterized XSLT to get the nodes and produce the HTML.

For adding records, you will do somewhat the opposite. Create your basic
XML form (like a VB form), post the data back to the server, and load and
process the XML document there.

BE SURE TO TAKE INTO ACCOUNT THAT MULTIPLE PEOPLE MIGHT BE EDITING THE DOCUMENT
AT THE SAME TIME. Some sort of Application level variable to indicate checkout
would work, but you'll have to figure out how to determine that a user has
cancelled the check-out.

I'm not really sure how XML Spy would help though. :-)
Jason at 2007-11-11 23:30:15 >
# 2 Re: Query XML data
Hi,

One easy way to achieve this is to write a simple server-side applet (servlet)
and then access your xml file via JDBC driver. You will be able to query
your XML file using standard SQL syntax. A type 4 JDBC driver for XML files
will be able to do that for you. Only type 4 JDBC driver for XML files is
the one of Sunopsis. You may have more information and download it here:
http://www.sunopsis.com/corporate/us/products/jdbcforxml/

Hoping that will help.

Omar

"JJ" <jjshea@sysmatrix.net> wrote:
>
>I have created an XML file the contains basic application info, eg. App
name,
>app class, primary contact, secondary, and app sponser. I would now like
>to create a way to query that file via a web interface.
>
>For example enter the app name, click query, and generate results based
on
>the XML file. Anyone have any suggestions/examples on how to accomplish
>this. I have been trying to use XML Spy and man am I confused.
>
>I would also like to create a seperate web interface for adding records.
>
>Thanks!!
Omar at 2007-11-11 23:31:21 >
# 3 Re: Query XML data
"Jason" <jason@creative_nospam_corp.com> wrote:
>
>"JJ" <jjshea@sysmatrix.net> wrote:
>>
>>I have created an XML file the contains basic application info, eg. App
>name,
>>app class, primary contact, secondary, and app sponser. I would now like
>>to create a way to query that file via a web interface.
>>
>>For example enter the app name, click query, and generate results based
>on
>>the XML file. Anyone have any suggestions/examples on how to accomplish
>>this. I have been trying to use XML Spy and man am I confused.
>>
>>I would also like to create a seperate web interface for adding records.
>>
>>Thanks!!
>
>The easiest way is to use "selectNodes" with an XPath query on the server
>side. This will give you back just the parts of the document that you are
>interested in.
>
>Now you have a choice - you can do all of this programmatically, writing
>code to parse the DOM nodes and formatting them into HTML, or you can use
>parameterized XSLT to get the nodes and produce the HTML.
>
>For adding records, you will do somewhat the opposite. Create your basic
>XML form (like a VB form), post the data back to the server, and load and
>process the XML document there.
>
>BE SURE TO TAKE INTO ACCOUNT THAT MULTIPLE PEOPLE MIGHT BE EDITING THE DOCUMENT
>AT THE SAME TIME. Some sort of Application level variable to indicate checkout
>would work, but you'll have to figure out how to determine that a user has
>cancelled the check-out.
>
>I'm not really sure how XML Spy would help though. :-)
>
Thanks...looks like I have a lot to learn to do this... :-D
JJ at 2007-11-11 23:32:13 >
# 4 Re: Query XML data
Nah, just use MSXML and XPath queries. That is the easy part. The hard part
is figuring out how to format your data so it's usable.

"Omar" <lacabessa@eudoramail.com> wrote:
>
>Hi,
>
>One easy way to achieve this is to write a simple server-side applet (servlet)
>and then access your xml file via JDBC driver. You will be able to query
>your XML file using standard SQL syntax. A type 4 JDBC driver for XML files
>will be able to do that for you. Only type 4 JDBC driver for XML files is
>the one of Sunopsis. You may have more information and download it here:
>http://www.sunopsis.com/corporate/us/products/jdbcforxml/
>
>Hoping that will help.
>
>Omar
>
>"JJ" <jjshea@sysmatrix.net> wrote:
>>
>>I have created an XML file the contains basic application info, eg. App
>name,
>>app class, primary contact, secondary, and app sponser. I would now like
>>to create a way to query that file via a web interface.
>>
>>For example enter the app name, click query, and generate results based
>on
>>the XML file. Anyone have any suggestions/examples on how to accomplish
>>this. I have been trying to use XML Spy and man am I confused.
>>
>>I would also like to create a seperate web interface for adding records.
>>
>>Thanks!!
>
Jason at 2007-11-11 23:33:24 >
# 5 Re: Query XML data
Do you have or know where I can get any examples to hack away at?

Thanks, I really appreciate the response. It all seems so confusing...
JJ at 2007-11-11 23:34:19 >
# 6 Re: Query XML data
"JJ" <jjshea@sysmatrix.net> wrote:
>
>Do you have or know where I can get any examples to hack away at?
>
>Thanks, I really appreciate the response. It all seems so confusing...

Let me preface this by saying I don't work for Wrox Press, nor do I own any
stake in Wrox Press. I just happen to use and like their books.

They have a book out called "Professional XSL." There is a whole section
near the beginning of the book that explains XPath in great detail, with
lots of examples. Once you figure it out, you will wonder how you ever got
along without it.

For those who are less inclined to spend $50, the microsoft web site has
some good reference material on XSL. It's more geared toward those who are
already familiar with how it works, but if you are one of those people who
just figures things out easily, try there first.
Jason at 2007-11-11 23:35:18 >
# 7 Re: Query XML data
Thanks!! I really appreciate the advice...will try MS first and the book
if all else fails. XML is really cool stuff!
JJ at 2007-11-11 23:36:17 >
# 8 Re: Query XML data
MSXML is a real Pain is the butt. The Java Interfaces for XML DOM are much
more practical and far more useful. But if you are only developing on Windows
and for Windows and not using Java use MSXML, otherwise, Xerces is a great
tool. http://xml.apache.org
Paul at 2007-11-11 23:37:20 >