|
Scripting is necessary if you want to use the DOM to process XML. If you don't want to do that, you can use XSLT.
XSLT is pretty cool, but it is quite challenging to master. You can take a look at 2 XSLT articles I wrote (while I was still using the name MarSCoZa).
|
|
|
|
|
One option is to use th DSO (Data Source Object) and a tiny bit of scripting (2-3 lines) to bind a control like a lisst box to an XML data source. Other than that, you can combine your XML with XSL to get IE to render an HTML-like document.
Erik Westermann
Author, Learn XML In A Weekend (Summer 2002)
|
|
|
|
|
Definitely do some reading at TopXML
|
|
|
|
|
Check out an article about CMarkupArchive by Jonathan de Halleux.
I use it in my apps.
|
|
|
|
|
Hi,
I've just got started with XML and VC6.0 (thanks to Tom Archer : http://codeguru.earthweb.com/xml/XMLDOMFromVC.html - great explanation/tutorial !!!) and I'm wondering how I can write data back to an XML file. I use the DOM as described in the article to read data from a file to internal datastructures - but I need to update different values in my XML file after updating the datastructures. How is this done most easily ? Currently, I see two ways of doing it : writing the XML file as ascii based on the data or using the DOM to generate a file. The first I can do ;o) - but how is the latter done ? And is that the "right" way to do it ?
Thanks in advance.
Best regards
Jan Hansen
|
|
|
|
|
u have seem to have solved the question about retrieving data.
XML DOM supports for Data insertion . Additionally it is advantageous as you will follow a syntax to add data . In case the DOM object could not add data it will notify . I think that using the DOM to insert Data is the way to go about this .
Also try exploring SAX .
|
|
|
|
|
Use the DOM. To set the value of an element use the same method you used to get the text, but instead set it.
Finally call the save method of the DOMDocument to save your DOM as an XML file.
Drinking In The Sun
Forgot Password?
|
|
|
|
|
You can use DOM to both modify data ( change values of existing nodes) and to modify the structure of your XML (Add or remove nodes).
DOMDocument has functions like CreatNode, CreateElement etc. Once you create a Node you can insert it or append it to an existing to node in your XML. Think of it as dealing with a tree structure.
Changing the value is easier. You just set the new value.
For example node.firstChild.Attributes.getNamedItem("blah").Text = "Yoooo Hoooo"
This will find an attribute named blah in your node and set its text to "Yoooo Hoooo"
You can try doing this yourself by editing the text but that would be reinventing the wheel.
Hope this helped. You may want to look into MSDN for more precise syntax and examples.
|
|
|
|
|
Thanks a lot !
I have looked (a little) at the "root-object", and there doesn't seem to be a "flush-to-disk" operation. During the lifetime of my application, I would like to ensure that changes to the data in the file are written - just to prevent a crash of the framework I'm working inside from deleting changes. Any idea how this is done ? Or do I have to sort of close the document?
/Jan
|
|
|
|
|
You need to look up help/documention for DOMDocument. It has a funtion called save that will save your XML. DOMDocument is where you load your XML. Then you use the nodes to manipulate the content. Then you save the DOMDocument.
|
|
|
|
|
Hi all, and thanks a lot for the help so far.
I now read data, delete some data from my XML tree ,and insert some data. Then I save the data to the file I loaded it from. Everything works fine - except for the formatting. I tend to format my XML data C-like, with tabular indents etc. This is kept in the part of the XML tree not modified from C++ - but the data added from C++ is written in one long line like this
<parent><child1>blah<child2>blah
- any way I can ask the XML engine to format things "my way" or a "standard way". By the way, the data not modified from C++ is getting (damn, whats the word...) truncated/fitted/"replace-one-or-more-newlines-with-only-one-newline". But tabs are kept.
Any hints, oh allmighty gurus of knowledge ;o)
Thanks in advance
/Jan
|
|
|
|
|
|
I want some child elements in an element to repeat. But I also don't care what order. I cant use the "all" compositor because the maxOccurance can only be 1. Here's what I have tried but I still don't have the result I want. The way I thought this should work is "line" and "field" should repeat as many times as needed.
<xsd:element name="group">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="name" minOccurs = "1" maxOccurs ="1"/>
<xsd:choice minOccurs = "0" maxOccurs = "unbounded">
<xsd:element ref="line" minOccurs = "0" maxOccurs = "unbounded"/>
<xsd:element ref="field" minOccurs = "0" maxOccurs = "unbounded"/>
</xsd:choice>
<xsd:element ref="TextFieldGroup" minOccurs = "0" maxOccurs = "unbounded"/>
</xsd:sequence>
<xsd:attribute name="groupType" use = "optional"/>
</xsd:complexType>
</xsd:element>
Any ideas on what I can do?
nay
|
|
|
|
|
I'm quite late in the day to XML and have only used XSD schema.
Is there a way to get a typed value from a XML DOM, particularly in the case of a xsd:dateTime type, without explicitly going through the SOM to find the type. I am look for something not too dissimilar to nodeTypedValue for XSD.
Timezoned dates and times are a particulr problem but I've just stumbled on a newsgroup thread that uses XSD but sets the nodeType to the XDR equivilent to make getting and setting values within the DOM easy. I was planning to include the XDR type as a string in the XML, and take the hit of xdr being non-standard or dissappearing.
Al.
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 there, I am very new to the new technologies (.NET and XML etc) because my work as a developer at this company does not allow for further training.....
My question, I work alot with databases (access mostly).... how will XML make my life better? I have read in MSDN about it a bit, but would like to know the exact uses etc, because I am getting confused by what other people tell me.
Thanks
|
|
|
|
|
There was a discussion about this in this earlier thread.
Basically what's nifty about XML is the fact that it is plain text, making it very generic. The basic XML concept is very simple, and it has a great many uses.
|
|
|
|
|
As far as uses go you have to open your mind a little. One that is very attractive to me is being able to integrate data in a more data driven nature. Take a look at the Apache Cocoon framework for a sample of what I mean by this.
To be conscious that you are ignorant of the facts is a great step towards Knowledge. Benjamin Disraeli
|
|
|
|
|
XML is awesome for several reasons.
Number one is that it is standard. This is the prime reason XML should be considered for anything at all.
Next, it is rigid, and fails with a parse error if it is not. This strongly encourages clean files, and helps with performance, among other things.
Another thing is XSL. Any standard XML document could be transformed into any sort of file with this powerful technology. Raw ASCII, HTML, DHTML, perhaps even things like postscript and CSS.
The XmlDOM and XPath. This lets any program work with XML in a standardized way. Most programs I make with Xml support use the Dom extensivly.
|
|
|
|
|
XML, the downside:
-XML is a lot slower when searched, compared with normal database queries.
-XML adds a lot of overhead, means bigger DB
-XML parsers are usually slow
-.NET implementation of XML is REALLY SLOW and requires managed code, which sucks hard
XML, the upside:
-universal
-simple tree structure: even a child can read it
-can be created/edited with NOTEPAD, the best application ever written
////////////////////////////////////////////////////////////////////
// NOW THE UPSIDE THAT YOU WERE ASKING ABOUT
//
// you can put in a single DB cell a complex and dinamic structure!
// That means that the information saved in the DB can have a dinamic structure WITHOUT changing the DB!!
////////////////////////////////////////////////////////////////////
|
|
|
|
|
Miguel Lopes wrote:
-XML adds a lot of overhead, means bigger DB
Have you ever zipped/compressed an XML file?
Man, I grinned from ear to ear when I saw the compression ratio. Zip loves all those repetitive tags.
So for transfer it is not as big a problem as some people make out. Of course when you are working with the XML it has to be unzipped and then the size can be a pain.
regards,
Paul Watson
Bluegrass
Cape Town, South Africa
The greatest thing you'll ever learn is just to love, and to be loved in return - Moulin Rouge
Alison Pentland wrote:
I now have an image of you in front of the mirror in the morning, wearing your knickers, socks and shoes trying to decided if they match!
|
|
|
|
|
The problem is when you are working with a speed-demanding DB system, when the client workstations need almost real time feedback from the DB. If i want to conduct a search inside each XML string (if you treat it as a stream) for each row in a DB table, and you also have to unzip it first, the overall system performance is heavly reduced.
For transfers, no problem. I agree with you.
Best Regards
|
|
|
|
|
Hello;
I want to update my XML file by XSXML40. But i have no idea how can i do that. The main problem is, i don't want to save (or write) whole file after update a record.
How can i update a record in XML file (I don't want to use DOM).
Thank you...
Ahmet Orkun GEDiK
|
|
|
|
|
SAX.
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".
|
|
|
|
|
how do we display the selected value in select box(drop down) in xsl & xml. All the values for drop down are selected thru' xml file.
|
|
|
|
|
Just to be clear: do you want to use XML/XSL to do something to your select boxes in response to a client-side event?
|
|
|
|