|
|
you know, I've had so much trouble with path syntax and checking if GetNode type statements returned null or not, that I started putting together my own short list of XML "stuff", but it hasn't really evolved into a useful tutorial. The hardest thing for me is still that "I just want to get data out like it was Access or a *.ini file, or a flat file", and the XML DOM sometimes seems to make what should be easy , difficult. (once it works it is fantastic)
Your tutorial was very helpful to me and my current project - I started out attempting something like what was in C++ Journal in the January issue , where I specify all the structs/variables for our project in XML, and then I generate the C++ code from that, I generate the C++ code in to read all the variables and populate the structs from the XML file, I change an MFC dialog on the fly to get or set variables in the data in my config screen. I started thinking at the beginning - here I have these different ways of formatting what is essentially the same data - I have C++ code, I have *.h include files, I need *.ini files, I need to edit my MFC dialog - why can't I just feed it all off the XML and use that to unify these various data structures? I got it working, but explaining it to our engineers has got me to back off from trying to force them to use the generating features. But it is still very handy to have C++ code plus the min/max validation data, the comments that explain what that variable is, the list of potential values, etc. all in one place. Someday somebody is going to make some money by providing a tool where we can specify data in XML, because when a guy creates a new variable, if he knows what the max/min values are to be, wouldn't be great if he could spell all that out in one place, and then it would be useable in his program, and all the other developers were doing the same thing, and multiple variables weren't created for the same purpose, etc.
Oh well, sorry for the long text. I could not live without the tutorials at CodeGuru and CodeProject (at least as a Windows/MFC developer). Your tutorial was very easy to understand and helpful.
|
|
|
|
|
Todd.Harvey wrote:
I just want to get data out like it was Access or a *.ini file, or a flat file", and the XML DOM sometimes seems to make what should be easy , difficult
Now that's an understatement
Todd.Harvey wrote:
Your tutorial was very easy to understand and helpful
Thanks!
I'll give some thought to your other remarks as you might be onto something there...
Cheers,
Tom Archer
Author, Inside C#
Please note that the opinions expressed in this correspondence do not necessarily reflect the views of the author.
|
|
|
|
|
Actually, I've updated that tutorial a great deal for an XML chapters I just did for my MFC book. I'll post it some time this weekend.
Cheers,
Tom Archer
Author, Inside C#
Please note that the opinions expressed in this correspondence do not necessarily reflect the views of the author.
|
|
|
|
|
I have an application that collects a bunch of data and stores relevant information in an XML file. A subset of the data is to be written to a CD-ROM, and a set of HTML pages are created with content customized from the contents of the XML file, to provide an easy user interface to the contents of the CD.
The problem is that some of the data that is collected is stored in TIF files, with the filenames stored in the XML file. Using the HTML [a] tag with "href=img.jpg" makes a nice link so the jpg image is displayed, but this doesn't seem to work with TIF files. Can't Internet Explorer display tif files from within HTML?
From my desktop, when I double click on a tif file, I get this "Imaging for Windows" application that displays the file. Well, that's alright, but how can I get that same thing to happen from my HTML link? How can I start an application with a specific file as an argument from within HTML?
Only because these HTML files are being generated from the contents of the XML file did I think it appropriate to try this forum. Thanks, too, for all those who helped me get the XML file "formatted" so it could be seen in an editor.
Dave
"You can say that again." -- Dept. of Redundancy Dept.
|
|
|
|
|
Dave,
IE should recoginise the image/tiff type
Ref:
http://msdn.microsoft.com/library/default.asp?url=/workshop/networking/moniker/overview/appendix_a.asp
I have QuickTime loaded on my system and all of the following work fine.
<object width=200 height=200>
<param name="src" value="yourfile.tif">
<embed width=200 height=200
src="MyFile.tif" type="image/tiff">
</object>
<embed width=200 height=200
src="MyFile.tif" type="image/tiff">
some comments may also be found at;
http://www.alternatiff.com/howtoembed.html
I know nothing of there viewer. Which could be your issue. IE knows the filetype but does not have a viewer for it.
To be conscious that you are ignorant of the facts is a great step towards Knowledge. Benjamin Disraeli
|
|
|
|
|
Michael,
Thanks for your comments. I was able to finally figure out what was going on after much research, reading, testing, and frustration. Here's a summary, which may be of help to others.
Web browsers (IE and Netscape Navigator, and apparently on both PCs and Macs) are not able to view TIFF files as a native format (like for BMP, JPG, and GIF). They all require help, either from a TIFF plugin for IE, or "helper applications" for NN. The Alternatiff product is a free plugin so that IE can display TIFF files.
The other option, though, is that IE (and I'm assuming NN also) uses the file associations to initiate the proper program to display files that IE does not recognize, such as .xls Excel spreadsheets or .doc Word files. With html links to those files, the corresponding app loads the linked file and displays it in the browser. This is also seen frequently with .pdf files when Adobe Acrobat starts up.
This should have worked on my machine for TIFF files, as when I double click on a file from the desktop, the Imaging For Windows application (either from Wang or Kodak) started up with the file displayed. But, it was not working for the same file in an html href link. The problem turned out to be two entries in the registry, underneath the Software/Internet Explorer/Plugins path ... one entry for tif and one for tiff. Both were there, but had no values.
What this was causing, therefore, was IE to believe that there was a plugin installed for tif/tiff files, and that it should use that plugin to display the file in the browser window. Since the plugin entries were empty, IE didn't have an application to use, so it displayed an empty image. When I deleted those two entries in the registry, IE could find no plugin and defaulted to the file associations, as expected.
Dave
"You can say that again." -- Dept. of Redundancy Dept.
|
|
|
|
|
I'm generating some C code from XML, and now I want to generate sub Structs.
I know I can do the following (a child node of same name as parent node),
<struct "name"="top">value
<struct "name"="sub">value
But what I'm having problems with is getting the top-level structs with SelectNodes, and then getting sub-level structs with SelectNodes (or other select commands).
I've been doing things like:
//StructList = xDB->m_pDomDocument->getElementsByTagName("Struct");
StructList = xDB->m_pDomDocument->selectNodes("//Struct");
and have not gotten lucky yet.
|
|
|
|
|
I have not used any of the calls to return a selective list (just the entire list and then steped through it.)
I believe it is quite picky on having a bstr as the argument not a char array as you have. Try declaring a "CComBSTR txt;" and then using it.
What parser version are you using?
Depending on what you are looking for it may be more direct to use an xslt transformation.
To be conscious that you are ignorant of the facts is a great step towards Knowledge. Benjamin Disraeli
|
|
|
|
|
thanks much
I'm using MSXML v4 (current)
the quoted text is working . . . although come to think of it, I always use BSTR's when convering from CStrings (doing this in MFC)
xslt transformation - I have not yet had the courage to do that in C++ code
About stepping throught the list . . . actually, what I am trying to do is very,very similar to the MSDN example where they recursed through a node set and displayed all the nodes in a CTreeCtrl . . . maybe I'll go back and try to figure out the recursion that needs to be done. If I can recurse through the node tree and keep track of which nodes are child to which, it might be less complicated than I am making it.
|
|
|
|
|
have you looked at Ray Hayes demo?
http://www.codeproject.com/soap/iexmlparser.asp
This was with MSXML 3 but still applys to what you describe.
To be conscious that you are ignorant of the facts is a great step towards Knowledge. Benjamin Disraeli
|
|
|
|
|
thanks much, good demo, it does apply, and the comments below it were helpful too.
|
|
|
|
|
There is following problem:
Some application (remote COM server) produces
dynamically some JPGs. these files are to be
shown in browser of the remote client.
The current way the things work is the following:
The COM server writes the file to HDD , and returns
url to the file back to client (with other data ,
enclosed in xml file).
Client than reads the url and displays the image
from remote location.
The question is :
Is it possible to embed the JPG file _inside_ XML
file , and than is the client able to display
the JPG directly from XML ?
(or previously having saved it onto local drive ?)
If so, what software (COMponents) to use ?
I heard somewhere that in order to put binary data
into XML file , these data must be BASE64 coded.
What component to use for codeing/decoding
(is this component shipped with windows 2000/XP ?)
Thanx for answer
Michal Januszczyk
|
|
|
|
|
First,
yes you can embedded any data inside an XML data node.
I have encoded binary data just as a server would encoded it to send it to a browser and then decoded it on the other side. Take a look at this page as an explanation.
http://www.nacs.uci.edu/indiv/ehood/MIME/1521/05_Content-Transfer-Encoding.html#5.2
To be conscious that you are ignorant of the facts is a great step towards Knowledge. Benjamin Disraeli
|
|
|
|
|
In my current application, I am using SQLXML to access my data (including JPEG images) within SQL Server 2000. By using a mapping-schema to explicitly map the datatypes (from "image" to "base64binary"), the image is automatically encoded and decoded for me.
|
|
|
|
|
Hello everybody:
I wanna know what exatcly XML is.I find out that I can store some information in XML file and use it during runtime,but what is advantage or disadvantage of this method than using database?When should I use XML and when should I use Acees/SQLServer ? Is XML something more than storing some piece of inforamtion?Any suggestion would be appreciated. Thanks
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
One of the cool things about XML is the fact that it is just a string, making it very generic. This makes it very simple to send from one application to another, (or even one business to another) without having to worry about special software requirements.
Another advantage is that it is completely disconnected from a database. You could have a COM component which gets information from the database and returns it as XML. This makes it easier to split the layers of an application.
Then there's also XSLT (which is pretty cool once you understand it). And don't forget about .Net, which is very XML-happy.
|
|
|
|
|
Thank you MarSCoZa
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
First I would not compare it to a database. There are XML databases but an XML file and a database are not the same thing.
XML is a method to package data to then send in whatever protocal or format you choose. By using this method you can use standard tools to parse and extract (or create) the data. Also once in this form you have many tools to reformat the data as needed (XSLT...)
To be conscious that you are ignorant of the facts is a great step towards Knowledge. Benjamin Disraeli
|
|
|
|
|
Thank you Michael.
Mazy
"The path you tread is narrow and the drop is shear and very high,
The ravens all are watching from a vantage point near by,
Apprehension creeping like a choo-train uo your spine,
Will the tightrope reach the end;will the final cuplet rhyme?"Cymbaline-Pink Floyd
|
|
|
|
|
HI Mazy,
Log onto the MSDN site MSDN.microsoft.com and read the "extreme XML" column postings.
Alice thought that running very fast for a long time would get you to somewhere else. " A very slow kind of country!" said the queen. "Now, here , you see, it takes all the running you can do, to keep in the same place".
|
|
|
|
|
Hi Alex
Thank you for reply.I'll do it.
Mazy
"If I go crazy then will you still
Call me Superman
If I’m alive and well, will you be
There holding my hand
I’ll keep you by my side with
My superhuman might
Kryptonite"Kryptonite-3 Doors Down
|
|
|
|
|
Being extremely comfortable with XML, I'm finally learning some SOAP.
I know the following is a SOAP request, but can someone shed some
light on what each part represents?
POST /StockQuote HTTP/1.1
Host: www.stockquoteserver.com
Content-Type: text/xml; charset="utf-8"
Content-Length: 323
SOAPAction: Some-Namespace-URI#GetLastTradePrice
<SQ:Envelope
xmlns:SQ="http://schemas.xmlsoap.org/soap/envelope/"
SQ:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SQ:Body>
<m:GetLastTradePrice xmlns:m="Some-Namespace-URI">
<symbol>DIS</symbol>
</m:GetLastTradePrice>
</SQ:Body>
</SQ:Envelope>
Here again with the response package, I could really use some help
deciphering it:
HTTP/1.1 200 OK
Content-Type: text/xml; charset="utf-8"
Content-Length: nnnn
<SP:Envelope
xmlns:SP="http://schemas.xmlsoap.org/soap/envelope/"
SP:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SP:Body>
<m:GetLastTradePriceResponse
xmlns:m="Some-Namespace-URI">
<Price>34.5</Price>
</m:GetLastTradePriceResponse>
</SP:Body>
</SP:Envelope>
Thanks!!
Cheers,
Tom Archer
Author, Inside C#
Please note that the opinions expressed in this correspondence do not necessarily reflect the views of the author.
|
|
|
|
|
First your soap request and responce is packaged as a standard HTTP request and responce that is the first set of data in both of your samples.
Then internal to that you have a "data" section that is that meaningful part.
POST /StockQuote HTTP/1.1
This line is a stock HTTP post
Host: www.stockquoteserver.com
Who is it to
Content-Type: text/xml;
what is the type of data text and xml
charset="utf-8"
how is the dataset being used
Content-Length: 323
how much data is to be read from the socket being used.
you have an error in your sample here. The header block should be terminated with a blank line (not a line with blanks ok)
SOAPAction: Some-Namespace-URI#GetLastTradePrice
define namespace to apply to the child data
<SQ:Envelope xmlns:SQ="http://schemas.xmlsoap.org/soap/envelope/" SQ:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
root element of the XML document being sent. it includes the version etc of the request.
<SQ:Body>
start of the body of data to be made available to the soap process
<m:GetLastTradePrice xmlns:m="Some-Namespace-URI">
What routine on the server is being called and the namespace to use
<symbol>DIS
arguments to be made available to the routine processing the request. It will ask for them by name (like an envoriment variable). You only have one and it is not properly terminated.
</m:GetLastTradePrice>
end of info for this process
</SQ:Body>
end of body
</SQ:Envelope>
end of data to make it a well formed document.
Your responce is identical other than the header is that of a valid http responce vs request.
Take Care and when should I start looking for your book a the stores?
To be conscious that you are ignorant of the facts is a great step towards Knowledge. Benjamin Disraeli
|
|
|
|
|
Thanks Michael!
Michael A. Barnhart wrote:
Take Care and when should I start looking for your book a the stores?
Inside C# should be in the stores next week!!
Cheers,
Tom Archer
Author, Inside C#
Please note that the opinions expressed in this correspondence do not necessarily reflect the views of the author.
|
|
|
|
|