|
hi please anybody tell me how i can create xml file susing vb 6.0,its urgent
Thanks
|
|
|
|
|
Use the COM object of Microsoft.
Check your VB references for "Microsoft XML".
As far as I can remember....
Eran Aharonovich (eran.aharonovich@gmail.com )
Noviway
|
|
|
|
|
Hello...
Is it possible to add audio to an XML simpleviewer file that was created with Picasa or whatever file i would need to add the code to?
I have files titled: flashobject (jscript script file), imagedata.xml, the index.html, a readme, viewer (flash player movie file) and then the 2 image folders.....
I can provide the code..... Any help so much appreciated!
thanks so much.
|
|
|
|
|
Hey
So I have a XML with DataSet in it, in the DataSet I have 2 DataTables, in each DataTable I have a Unique ID, and I did to this row, auto-inc, and don't allow DBNull, and it's readonly.
So when I try to do NewRow(), and add it without setting the ID column, it throws an Exception DataColumn 'ID' can't allow DBNull.
So how can I do it as UNIQUE ID? do I need to allow DBNull?
|
|
|
|
|
Unique ID is similar to a primary key in some ways. It doesn't allow null. If you need nulls, you should use a regular data type with a more advanced constraint.
Keep in mind that XSD uinque IDs are document (DataSet) unique, not table unique.
|
|
|
|
|
But how can I insert a row in the DataTable with a unique ID (the next that should be)?
like if i have 5 rows and IDs 1-5, how can I add a new row with ID = 6? when it's readonly (can't edit it) and doesn't allow nulls?
|
|
|
|
|
If whatever component you're using to manipulate the XML doesn't automatically manage unique IDs, your best bet is probably to use int fields for your IDs and use a library function to manage this.
It's easy enough to write your own, although this is a well-solved problem so there's most likely one in whatever system you're running. Basically, you just need to store the next ID for each table, and write a function to retrieve it and increment each time.
|
|
|
|
|
Hi,
I wrote a program to extract part of XML elements, fill in the dataset with extracted elements,and display them in dataGridView (C++).e.g. : to extract only ADDRESSES and display the Id,Street,Postcode, city and country as the table columns in dataGridView
<MEMBER>
<GENDER>FEMALE</GENDER>
<AGE>35</AGE>
- <ADDRESSES>
- <ADDRESS>
<ID>1</ID>
<STREET>cranbrook ave</STREET>
<POSTCODE>1231231</POSTCODE>
<CITY>NOTTINGHAM</CITY>
<COUNTRY>UK</COUNTRY>
</ADDRESS>
- <ADDRESS>
<ID>2</ID>
<STREET>Wisteria Lane</STREET>
<POSTCODE>2452434</POSTCODE>
<CITY>FAIRVIEW</CITY>
<COUNTRY>US</COUNTRY>
</ADDRESS>
</ADDRESSES>
</MEMBER>
I have done the extraction with Xpath, append the extracted xml results node list with Stringbuilder and display them first in a text box. Then a dataset read the text box and display the result in dataGridView.
However, i would like to enable users edit the dataGridView and save the changes to the original Xml file. Could anyone suggest how I could get around it? I am a newbie in XML and I am sorry if it's a trivia >_<
Many thanks in advance,
Shar
-- modified at 21:35 Saturday 27th May, 2006
|
|
|
|
|
Take a look at System.Data.DataSet.ReadXml(...) and then binding the appropriate tables to the DataGridView object.
|
|
|
|
|
Hello,
Many thanks for you reply I managed to display the extracted element (addresses) in DataGridView (binded to dataset that contains <ADDRESSES>) fine, but could not figure out a way to update the original xml file if the dataGrid is updated.
For example, I have the following in "addressTry.xml" :
<MEMBER>
<GENDER>FEMALE</GENDER>
<AGE>35</AGE>
- <ADDRESSES>
- <ADDRESS>
<ID>1</ID>
<STREET>cranbrook ave</STREET>
<POSTCODE>1231231</POSTCODE>
<CITY>NOTTINGHAM</CITY>
<COUNTRY>UK</COUNTRY>
</ADDRESS>
</ADDRESSES>
when user changes CITY to LONDON, the DataSet is updated. But I could not use DataSet.WriteXml(...) or XmlDataDocument.Save(..) to update original file as this will overwrite the whole xml file. i.e : the <MEMBER>,<GENDER>,<AGE> and their child elements will be deleted, replaced by only <ADDRESSES> elements from dataset.
So how could I update this to the original file (so only <ADDRESSES> element is affected, and <MEMBER>, <GENDER> and <AGE> stay the same?)
Many thanks for advice and suggestions,
Shar
-- modified at 13:44 Thursday 1st June, 2006
|
|
|
|
|
sepsep06 wrote: (binded to dataset that contains <addresses>)
that is the problem. The DataSet should load the entire file not just a part of it. XML DOM and/or serialization can only write the whole file. Updating discrete fields of data is what a Database is for not an XML file.
|
|
|
|
|
Hello,
Thanks again for your reply . For some reason I could not use database and all I have is an XML file. However, I have managed to solve this problem by forcing it to delete the <ADDRESSES> original children element first; and then use XpathNavigator to append children (from new updated dataset)to <ADDRESSES>. I dont think this is a very good way but it is the only working way I can think of.
Many thanks and regards,
Shar
-- modified at 20:34 Thursday 1st June, 2006
|
|
|
|
|
Hi
When I pass & to the function putnodeValue() under the IXMLDom, its converting it to &. The same thing happens for &gr; also, when &gr; is passed the value set is &gr.
How to avoid this, I want the exact value to be set which I am passing.
Pls help
|
|
|
|
|
http://www.w3.org/TR/2004/REC-xml-20040204/#charsets[^]
The following quoted from that page:
The ampersand character (&) and the left angle bracket (<) MUST NOT appear in their literal form, except when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section. If they are needed elsewhere, they MUST be escaped using either numeric character references or the strings "&" and "<" respectively. The right angle bracket (>) MAY be represented using the string ">", and MUST, for compatibility, be escaped using either ">" or a character reference when it appears in the string "]]>" in content, when that string is not marking the end of a CDATA section.
-- modified at 23:46 Friday 26th May, 2006
|
|
|
|
|
Actually my problem is I am reading a CSV file and conveting it into XML, when one of the comma seperated value is &. I read it and set the value to the XML using IXMLDomNode's put_nodeValue() function in VC++. But the resulting output is &amp;.
Similarly when I pass > its converted to &gt;
How to over come this problem, the put_nodeValue() function is converting & to &
Is there any escape sequence to be added so that & is read as &
Thanks in Advance
|
|
|
|
|
If your source data contains an "&", it will be converted to "&" and placed into your XML document. When you parse your XML document, the "&" will be converted back to a "&".
However, you must use CDATA to store "&" as is:
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
namespace AmpXml
{
class Program
{
static void Main(string[] args)
{
XmlDocument doc = new XmlDocument();
XmlNode node = doc.CreateNode(
XmlNodeType.Element, "amps", string.Empty);
doc.AppendChild(node);
node = doc.CreateNode(
XmlNodeType.Element, "amp", string.Empty);
doc.DocumentElement.AppendChild(node);
XmlCDataSection cdata = doc.CreateCDataSection(
"&&>>&&<<&&");
node.AppendChild(cdata);
Console.WriteLine(doc.OuterXml);
}
}
}
-- modified at 13:00 Saturday 27th May, 2006
|
|
|
|
|
I have downloaded a XML_PARSER code from this site but whenever a & is found its automatically converting it into & even if > its converting to &gt;
How to avoid this
Pls help me
|
|
|
|
|
|
Hi to All
I don't know how to use AJAX in ASP. So please if any one knows plz. help me.
If u have some ex. then plz. send me on jesalrana77@gmail.com
OK
|
|
|
|
|
Hello,
Has anyone ever seen/created such an animal?
I'm looking for a sample of a code generator that will generate code (preferably one that uses C# and the XMLTextWriter) to create an XML document structure based on an XML file as input.
I have to build some classes that allow me to generate some very complex/large/nasty XML documents for use in B2B exchange of data (like invoices, orders, etc.). A third party has dictated the structure and provided example XML documents. Instead of hand coding these classes, I'd like to be able to automatically generate them by using these example XML documents as input. This seems like a fairly easy task but I haven't sun across a demonstration of this yet.
An Example XML file (contents):
===============================
<myRootNode>
<myChildNode1>
<myChildNode2 myAttribute1="test"/>
. . .
</myChildNode1>
. . .
</myRootNode>
Example output from the code generator that takes the path of the xml file above (this is merely a simple example):
==================================================
// instantiate XmlTextWriter over file stream using UTF-8
XmlTextWriter tw = new XmlTextWriter(fileName, Encoding.UTF8);
// specify serialization details
tw.Formatting = Formatting.Indented;
tw.Indentation = 8;
tw.QuoteChar = '\"';
// No need for a start element
//tw.WriteStartDocument();
tw.WriteStartElement("myRootNode");
tw.WriteStartElement("myChildNode1");
tw.WriteStartElement("myChildNode2");
tw.WriteAttributeString("", "myAttribute1", "", "test");
tw.WriteEndElement(); // myChildNode2
tw.WriteEndElement(); // myChildNode1
tw.WriteEndElement(); // myRootNode
// No need for a start element
//tw.WriteEndDocument();
// close the stream
tw.Close();
Thanks for your time and input,
Josh Blair
Evergreen, CO
-- modified at 13:00 Thursday 25th May, 2006
|
|
|
|
|
why not use XSLT?
"What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum
led mike
|
|
|
|
|
led mike,
Can you explain how I would use XSLT to generate these XML documents from empty example ones? Do you mean to transform the empty document into one that is populated with the data values?
More background: the data that I will use to populate the values in these XML documents will be coming from an ERP system (ODBC).
Thanks for the recommendation and clarification.
Josh Blair
Evergreen, CO
|
|
|
|
|
Sorry I misunderstood the first post. It sounds like you have 2 issues.
1) Generate XML data from ODBC data source.
2) Not have hard-coded XML format (element and attribute names)
First, there must be a fairly wide variety of options to accomplish those goals. I certainly do not know all of them, here are a few I am aware of.
Before I start in on a software development solution, you might look into Biz Talk Server. I have never used Biz Talk myself (only read about it) but it is highly possible it would provide a completely configuration based solution.
There may be other products as well however if for whatever reason you need to develop a solution here are some ideas.
I believe #1 is simple because I think there is a Microsoft ODBC driver that is compatible with ADO.NET. Look on MSDN for that. Obviously it is not the fastest driver.
So if we assume you can use ADO.NET to access the data then you can use the XmlSerializer to generate the XML. The bare bones generation will use the table and column names from the data source to generate the XML. Assuming that works for you then you are done and nothing is hard-coded.
If those names do not meet your requirements then you have many choices you can use to change the element and attribute names. There are Attribute (Declarative) mechanisms you can use to effect the Serialization names that are created. Again you can read about this on MSDN.
In another potential solution you could use the raw XmlSerializer XML and process those results into the desired XML using XSLT. Then the XSLT becomes in effect your "template" that can be changed to modify the end result XML without any compilation required. However it would be somewhat slower than another solution, Custom Serialization.
Basic custom serialization would in effect be hard coded. If you wanted to change the output XML format it would require compiling. However you could develop a system that reads in an XML format or mapping document and uses that to generate the output XML. This is more work but would result in you being able to change the XML mapping documents to change the output XML without any compilation involved.
Hope that helps
"What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum
led mike
|
|
|
|
|
led mike,
Thanks again for your information. It is very helpful.
I must not be stating the problem and desired results appropriately. I apologize. I will try to explain myself better...
Good news: I wrote the code generator that I was looking for myself. It is a simple solution that I may post if anyone is interested. I'll give you a description of what it does: It is a console app written in C# that takes a path/filename to an example XML file as a parameter and then subsequently generates the code necessary to create a duplicate xml structure in code using the XmlTextWriter. Very simple but effective. Once this generator does its thing, you can put the output into your own class files and use them as a starting point. You can add public properties and the like to these class files and then you use them to generate XML files from ODBC queries or any other datasources. Does this make any sense? I still my not be articulating this very well.
Here is an example of what you can do with these objects once you get them built (pseudo code only):
XMLInvoice invoice = new XMLInvoice();
invoice.InvoiceNumber = "INV12355"; // may come from helper method or database query or something like that...
invoice.OtherField1 = "whatever";
invoice.OtherField2 = "whatever";
. . .
// in a looping construct that may result from records obtained from a query or the like
invoice.Lines.Add(param1, param2, etc...);
invoice.Lines.Add(param1, param2, etc...);
invoice.Lines.Add(param1, param2, etc...);
. . .
invoice.CreateXML(); // this is where the XmlTextWriter is used to generate the big nasty XML message (that the code generator helped create)
. . .
invoice.Save(filename); // for archiving purposes
. . .
B2BEngine b2b = new B2Bengine(); // object that knows how to communicate via HTTP with customers, suppliers, etc.
CustomerInfo custInfo = new CustomerInfo("MyCustomer123"); some settings info about particular customer (Ip address of server, credentials, etc.)
b2b.Send(invoice, custInfo); //
Please me know if this helped to explain my situation an better. Also, this may lead you to believe that I am approaching the problem all wrong. If that is true, please let me know your thoughts...
Thanks again,
Josh Blair
Evergreen, CO
|
|
|
|
|
Josh Blair wrote: I must not be stating the problem and desired results appropriately.
Yes I still don't get it. Based on your latest post I still think your Goal is:
1) Generate XML data from ODBC data source
Is that correct?
If it is correct then yes I do believe it is possible that you are not taking advantage of the .NET Frameworks inherent power to accomplish this. The Library has very rich capacity to connect and consume Database data. Just as powerful are the XML libraries such as the XmlSerializer that I mentioned.
"What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum
led mike
|
|
|
|
|