|
Thanks for the help, i solved the problem
For Each row As GridViewRow In GrdImagesSel.Rows
Dim cbSi As CheckBox = row.FindControl("chkShowImage")
'Koppel Itemcode van de row aan productID en
If cbSi IsNot Nothing AndAlso cbSi.Checked Then
Dim productID As String = Convert.ToString(GrdImagesSel.DataKeys(row.RowIndex).Value)
Dim root As XmlNode = xmldoc.DocumentElement
Dim nodeList As XmlNodeList = root.SelectNodes("MNINT_Summary/Itemcode")
For Each productNode As XmlNode In nodeList
If productNode.FirstChild.InnerText = productID Then
Dim ShowImage As XmlElement = xmldoc.CreateElement("ShowImage")
productNode.AppendChild(ShowImage)
ShowImage.InnerText = "1"
End If
Next
Else
Dim productID As String = Convert.ToString(GrdImagesSel.DataKeys(row.RowIndex).Value)
Dim root As XmlNode = xmldoc.DocumentElement
Dim nodeList As XmlNodeList = root.SelectNodes("MNINT_Summary/Itemcode")
For Each productNode As XmlNode In nodeList
If productNode.FirstChild.InnerText = productID Then
Dim ShowImage As XmlElement = xmldoc.CreateElement("ShowImage")
productNode.AppendChild(ShowImage)
ShowImage.InnerText = "0"
End If
Next
End If
Next
|
|
|
|
|
Hi,
I hope I'm on the right forum.
My question is: how to create sitemap.xml file for your website? Is there any software? I see a lot of webmasters talking about how important is to have sitemap.xml.
Thanks!
|
|
|
|
|
|
|
Hi All,
I have some XML files which contains nodes word formatting nodes e.g..
w:pPr,w:r,w:t .
I want to see this XML file without word formatting.
Which tool or what setting i need to change to view this file without word formatting.
Thanks in Advance.
The secret of life is not enjoyment
but education through experience.
- Swami Vivekananda.
|
|
|
|
|
Hello Coders,
Im facing a problem building a C#.net code that will build me the following XML page:
<?xml version="1.0"?>
<chores>
<day title="some title">
<job a=".." b="text.." c="..text.." d="d..."/>
<job a=".." b="text.." c="..text.." d="d..."/>
<job a=".." b="text.." c="..text.." d="d..."/>
</day>
<day title="some title">
<job a=".." b="text.." c="..text.." d="d..."/>
<job a=".." b="text.." c="..text.." d="d..."/>
<job a=".." b="text.." c="..text.." d="d..."/>
</day>
<day title="some title">
<job a=".." b="text.." c="..text.." d="d..."/>
<job a=".." b="text.." c="..text.." d="d..."/>
<job a=".." b="text.." c="..text.." d="d..."/>
</day>
</chores>
I've tried hundreds of codes, nothing worked the way i need it. i will appreciate any help PLEASE.
What im trying to do is the following:
I have a page that has 4 textboxes, each one is supposed to save some value .. lets say a,b,c,d..
Another textbox is for the day attribute which is TITLE according to my example
I need to add whenever i need a DAY. with it's attribute. and "jobs" like that example.
whenever i need to make a new "DAY" i need it do be after the last one. i mean i need it to update the new <DAY> after the last one's
and all of that i need it to come before the each time i update the xml file</chores>
Please i'd really appreciate any help with this. im new to XML and im trying to make an XML management page for some project.If what i've said wasnt clear im ready to explain again. Please tell me what to do and how to do it, or if you have any samples for handling such an issue it will be great too
|
|
|
|
|
Can you show us a little of what you tried?
What you are trying to do is maintaining a kind of database.
On the assumption that you really want it as xml-file :
option 1 : Read your file as XmlDocument and add nodes as you add entries.
option 2 : Create a dedicated class model with serializing/deserializing.
Both methods have as disadvantage that everything get loaded in memory. To prevent that you might have to split your model in multiple files.
Google for XmlDocument and/or XSD utility.
If you need further clarification, just ask.
|
|
|
|
|
i've tried this code for example
XmlDocument XDoc = new XmlDocument();
XmlElement Xchores = XDoc.CreateElement("day");
XmlElement XElemRoot = XDoc.CreateElement("chores");
XElemRoot.AppendChild(Xchores);
Xchores.SetAttribute("label", "" + this.txtBoxCat.Text + "");
XDoc.AppendChild(XElemRoot);
XmlElement Xjob = XDoc.CreateElement("job");
while (this.Label5.Text == "1")
{
Xjob.SetAttribute("a", "" + this.txtBoxAbout.Text + "");
Xjob.SetAttribute("b", "" + this.txtBoxSize.Text + "");
Xjob.SetAttribute("c", "" + this.txtBoxPrice.Text + "");
Xjob.SetAttribute("d", "" + this.txtBoxAmount.Text + "");
Xchores.AppendChild(Xjob);
XDoc.Save("chores2.xml");
}
and ive tried it by making a dataset of the elements
DataSet ds = new DataSet();
ds.ReadXml("chores2.xml"); DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("a"));
dt.Columns.Add(new DataColumn("b"));
dt.Columns.Add(new DataColumn("c"));
dt.Columns.Add(new DataColumn("d"));
DataRow dr = dt.NewRow();
dr[0] = ""+this.txtBoxSize.Text+"";
dr[1] = "" + this.txtBoxAbout.Text + "";
dr[2] = "" + this.txtBoxAmount.Text + "";
dr[3] = "" + this.txtBoxSize.Text + "";
dt.Rows.Add(dr);
ds.Tables.Add(dt);
ds.Relations.Add(new
DataRelation("myrel", ds.Tables[1].Columns[0], ds.Tables[0].Columns[0]));
ds.Relations[0].Nested = true;
ds.WriteXml("chores2.xml");
and i've tried it by getting the values from an access database and save them as an XML file
also that didnt help approaching my goal
OleDbConnection con = new OleDbConnection();
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db.mdb";
OleDbDataAdapter da = new OleDbDataAdapter("Select * from job1", con);
DataSet ds = new DataSet("chores");
DataTable xjob = new DataTable();
xjob = xjob.Tables["job"];
da.Fill(ds, "day");
ds.WriteXml("chores2.xml");
*/
string jobName = this.TextBox2.Text;
OleDbConnection con = new OleDbConnection();
con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=db.mdb";
OleDbDataAdapter da = new OleDbDataAdapter("Select * from "+jobName+"", con);
DataSet ds = new DataSet("chores");
while (this.Label5.Text == "1")
{
da.Fill(ds, "job");
DataTable dt = new DataTable("job");
dt = ds.Tables["job"];
foreach (DataColumn dc in dt.Columns)
{
dc.ColumnMapping = MappingType.Attribute;
}
}
ds.WriteXml("chores2.xml");
and i tried the XMLDocument, also didnt work exactly how i want it
i would be more than happy if you can explain me what do you mean by
:
option 2 : Create a dedicated class model with serializing/deserializing
|
|
|
|
|
Your approach with XmlDocument in itself works, I tried your code.
What you need to to there is first checking if the file exists and if so xDoc.Load(<file>); .
FileInfo fi1 = new System.IO.FileInfo(@"c:\temp\chores2.xml");
if (!fi1.Exists)
{
XDoc.Load(@"c:\temp\chores2.xml")
}
else
{
XmlElement XElemRoot = XDoc.CreateElement("chores");
XDoc.AppendChild(XElemRoot);
}
To add a job to a particular day you need to find the node with the right title :
XDoc.SelectSingleNode("descendant::day[@title='YourTitle']");
You can now add your jobs to it.
About option 2, MS has a utility called XSD. On my PC it's in :
C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\xsd.exe
With your xml you can generate an xsd, and with the xsd you can generate a .cs file.
It has all the classes and attributes you need. You can and should edit it to suit your needs.
The only thing left to do is write a serializer and a deserializer.
The code would look something like this (I removed all attributes)
public partial class chores {
private choresDay[] itemsField;
public choresDay[] Items {
get {
return this.itemsField;
}
set {
this.itemsField = value;
}
}
}
public partial class choresDay {
private choresDayJob[] jobField;
private string titleField;
public choresDayJob[] job {
get {
return this.jobField;
}
set {
this.jobField = value;
}
}
public string title {
get {
return this.titleField;
}
set {
this.titleField = value;
}
}
}
public partial class choresDayJob {
private string aField;
private string bField;
private string cField;
private string dField;
public string a {
get {
return this.aField;
}
set {
this.aField = value;
}
}
public string b {
get {
return this.bField;
}
set {
this.bField = value;
}
}
public string c {
get {
return this.cField;
}
set {
this.cField = value;
}
}
public string d {
get {
return this.dField;
}
set {
this.dField = value;
}
}
}
You would use it :
chores chores = new chores();
chores.Items = new choresDay[];
chores.Items[0] = new choresDay;;
chores.Items[0].job = new choresDayJob[];
chores.Items[0].job[0] = new choresDayJob();
chores.Items[0].job[0].a = this.a;
chores.Items[0].job[0].b = this.b;
Good luck!
|
|
|
|
|
Hi Estys,
First of all thank you a lot for your help and time, i really appreciate that.
Second, i think im gonna take option #1 lol.
Anyway, this is the code i've made for now, im not sure about it but i'd really appreciate more help.
protected void Button1_Click(object sender, EventArgs e)
{
XmlDocument XDoc = new XmlDocument();
FileInfo fi1 = new System.IO.FileInfo("chores2.xml");
if (!fi1.Exists)
{
XDoc.Load("chores2.xml");
}
else
{
XmlNode root = XDoc.DocumentElement;
XDoc.SelectSingleNode("descendant::day[@title='"+this.dropdwnlst.selectedvalue+"']");
XmlElement Xjob = XDoc.CreateElement("job");
Xjob.SetAttribute("a", "" + this.txtBoxProduct.Text + "");
Xjob.SetAttribute("b", "" + this.txtBoxSize.Text + "");
Xjob.SetAttribute("c", "" + this.txtBoxPrice.Text + "");
Xjob.SetAttribute("d", "" + this.txtBoxAmount.Text + "")
XDoc.Save("chores2.xml");
}
}
this is what im thinking about, i have 4 text boxes for the job attributes. with another DropDownList that through it i can choose what kind of a "DAY" according to the title i want to play with and add "jobs".
So, this cute line
XDoc.SelectSingleNode("descendant::day[@title='"+this.dropdwnlst.selectedvalue+"']");
is really great, but how i can control my selected node and enter the correct attributes
Xjob.SetAttribute("a", "" + this.txtBoxProduct.Text + "");
Xjob.SetAttribute("b", "" + this.txtBoxSize.Text + "");
Xjob.SetAttribute("c", "" + this.txtBoxPrice.Text + "");
Xjob.SetAttribute("d", "" + this.txtBoxAmount.Text + "")
to it?
Thanks again for your help.
|
|
|
|
|
Your form code should look like this :
public partial class choreForm : Form
{
XmlDocument xDoc = new XmlDocument();
public choreForm()
{
InitializeComponent();
}
private void choreForm_Load(object sender, EventArgs e)
{
FileInfo fi1 = new FileInfo(GetFileName());
if (fi1.Exists)
{
xDoc.Load(GetFileName());
}
else
{
xDoc.AppendChild(xDoc.CreateElement("chores"));
}
}
private void button1_Click(object sender, EventArgs e)
{
XmlElement xDay = xDoc.SelectSingleNode("descendant::day[@title='" + this.dropdwnlst.selectedvalue + "']") as XmlElement;
if (xDay == null)
{
xDay = xDoc.CreateElement("day");
xDay.SetAttribute("title", this.dropdwnlst.selectedvalue);
xDoc.FirstChild.AppendChild(xDay);
}
XmlElement xJob = xDoc.CreateElement("job");
xJob.SetAttribute("a", this.txtBoxProduct.Text);
xJob.SetAttribute("b", this.txtBoxSize.Text);
xJob.SetAttribute("c", this.txtBoxPrice.Text);
xJob.SetAttribute("d", this.txtBoxAmount.Text);
xDay.AppendChild(xJob);
}
private void choreForm_FormClosing(object sender, FormClosingEventArgs e)
{
xDoc.Save(GetFileName());
}
private string GetFileName()
{
return @"c:\temp\chores2.xml";
}
}
gimme 5 if you like this!
|
|
|
|
|
I LOVE IT!! this code is perfect!!!
i've been blessed by a genius coder
THANK U ALOT for ur time and help!! PERFECT )))))))))))))))))))))
|
|
|
|
|
Hi again thanks for your help with adding the XML data
i need to ask you another question
i've got my final xml file looking exactly as i need it to be
<?xml version="1.0" encoding="utf-8"?>
<chores>
<day label="111" title="asdasd">
<job a="2" b="22" c="22" d="22" />
<job a="2" b="22" c="22" d="22" />
</day>
</chores>
im trying to Edit this file in a dataGrid but its not working
my aspx page
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="EditTables.aspx.cs" Inherits="EditTables" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
<style type="text/css">
.style1
{
width: 100%;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
<table class="style1">
<tr>
<td>
<br />
<br />
Edit your Products tables<br />
</td>
</tr>
<tr>
<td>
<asp:DataGrid ID="DataGrid1" runat="server" AllowPaging="True"
AllowSorting="True" CellPadding="4" ForeColor="#333333" GridLines="None"
oncancelcommand="DataGrid1_CancelCommand"
ondeletecommand="DataGrid1_DeleteCommand" oneditcommand="DataGrid1_EditCommand"
onpageindexchanged="DataGrid1_PageIndexChanged"
onupdatecommand="DataGrid1_UpdateCommand" AutoGenerateColumns="False"
Width="890px">
<AlternatingItemStyle BackColor="White" ForeColor="#284775" />
<Columns>
<asp:TemplateColumn HeaderText=" label">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "label")%>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id="txtBoxTitle"
Text='<%# DataBinder.Eval(Container.DataItem, "label") %>'
runat="server" Height="21px" Width="80px"/>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="title">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "title")%>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id="txtBoxTitle"
Text='<%# DataBinder.Eval(Container.DataItem, "title") %>'
runat="server" Height="21px" Width="80px"/>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="כמות">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "a")%>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id="txtBoxAmount"
Text='<%# DataBinder.Eval(Container.DataItem, "a") %>'
runat="server" Height="21px" Width="80px"/>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="מחירון">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "b")%>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id="txtBoxPrice"
Text='<%# DataBinder.Eval(Container.DataItem, "b") %>'
runat="server" Height="21px" Width="80px"/>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="גודל">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "c")%>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id="txtBoxSize"
Text='<%# DataBinder.Eval(Container.DataItem, "c") %>'
runat="server" Height="22px" Width="80px"/>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:TemplateColumn HeaderText="מוצר">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "d")%>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox id="txtBoxProduct"
Text='<%# DataBinder.Eval(Container.DataItem, "d") %>'
runat="server" Height="22px" Width="80px"/>
</EditItemTemplate>
</asp:TemplateColumn>
<asp:EditCommandColumn CancelText="Cancel" EditText="Edit" UpdateText="Update">
</asp:EditCommandColumn>
<asp:ButtonColumn CommandName="Delete" Text="Delete"></asp:ButtonColumn>
</Columns>
<EditItemStyle BackColor="#999999" />
<FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
<ItemStyle BackColor="#F7F6F3" ForeColor="#333333" />
<PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
<SelectedItemStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
</asp:DataGrid>
</td>
</tr>
<tr>
<td>
<asp:Label ID="lblerror" runat="server" ForeColor="Maroon"></asp:Label>
</td>
</tr>
</table>
</asp:Content>
and this is my CS code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
using System.Globalization;
using System.IO;
using System.Data;
using System.Data.OleDb;
public partial class EditTables : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!User.IsInRole("Admin"))
Server.Transfer("login.aspx");
if (!(Page.IsPostBack))
{
DataGrid1.DataSource = LoadMyData();
DataGrid1.DataBind();
}
}
protected DataSet LoadMyData()
{
string sourceXml = Server.MapPath("~/xml/chores2.xml");
if (!(File.Exists(sourceXml)))
{
return null;
}
DataSet cachedDataSet = (DataSet)Session["table"];
if (!(cachedDataSet == null))
{
return cachedDataSet;
}
DataSet dataSet = new DataSet();
try
{
dataSet.ReadXml(sourceXml);
Session["table"] = dataSet;
}
catch (Exception e)
{
lblerror.Text = e.Message;
dataSet = null;
}
return dataSet;
}
protected void DataGrid1_EditCommand(object source, DataGridCommandEventArgs e)
{
DataGrid1.EditItemIndex = Convert.ToInt32(e.Item.ItemIndex);
DataGrid1.DataSource = LoadMyData();
DataGrid1.DataBind();
}
protected void DataGrid1_CancelCommand(object source, DataGridCommandEventArgs e)
{
DataGrid1.EditItemIndex = -1;
DataGrid1.DataSource = LoadMyData();
DataGrid1.DataBind();
}
protected void DataGrid1_DeleteCommand(object source, DataGridCommandEventArgs e)
{
DataSet dataSet = LoadMyData();
int row = Convert.ToInt32(e.Item.ItemIndex);
dataSet.Tables[0].Rows[row].Delete();
dataSet.WriteXml(Server.MapPath("~/XML/chores2.xml"));
Session["table"] = null;
DataGrid1.EditItemIndex = -1;
DataGrid1.DataSource = LoadMyData();
DataGrid1.DataBind();
}
protected void DataGrid1_UpdateCommand(object source, DataGridCommandEventArgs e)
{
DataSet dataSet = LoadMyData();
int row = Convert.ToInt32(e.Item.ItemIndex);
TextBox txtBoxLabel = (TextBox)e.Item.FindControl("txtBoxLabel");
dataSet.Tables[0].Rows[row]["label"] = txtBoxLabel.Text;
TextBox txtBoxTitle = (TextBox)e.Item.FindControl("txtBoxTitle");
dataSet.Tables[0].Rows[row]["title"] = txtBoxTitle.Text;
TextBox txtBoxProduct = (TextBox)e.Item.FindControl("txtBoxProduct");
dataSet.Tables[0].Rows[row]["a"] = txtBoxProduct.Text;
TextBox txtBoxSize = (TextBox)e.Item.FindControl("txtBoxSize");
dataSet.Tables[0].Rows[row]["b"] = txtBoxSize.Text;
TextBox txtBoxPrice = (TextBox)e.Item.FindControl("txtBoxPrice");
dataSet.Tables[0].Rows[row]["c"] = txtBoxPrice.Text;
TextBox txtBoxAmount = (TextBox)e.Item.FindControl("txtBoxAmount");
dataSet.Tables[0].Rows[row]["d"] = txtBoxAmount.Text;
dataSet.WriteXml(Server.MapPath("~/XML/chores2.xml"));
Session["table"] = null;
DataGrid1.EditItemIndex = -1;
DataGrid1.DataSource = LoadMyData();
DataGrid1.DataBind();
}
protected void DataGrid1_PageIndexChanged(object source, DataGridPageChangedEventArgs e)
{
this.DataGrid1.CurrentPageIndex = e.NewPageIndex;
DataGrid1.DataSource = LoadMyData();
DataGrid1.DataBind();
}
}
it keeps telling me whenever i load the page
DataBinding: 'System.Data.DataRowView' does not contain a property with the name a..
anyway the problem is here..
dataSet.Tables[0].Rows[row]["a"] = txtBoxProduct.Text;
i guess this line is not working for the xml attributes
int row = Convert.ToInt32(e.Item.ItemIndex);
how can i fix that to work with my xml?
|
|
|
|
|
Actually, your DataSet contains two Table s : day and job, I guess that's where the problems start.
I'm not very familiar with databinding, I would ask in another forum (as this whole question probably should have been ).
The problem is not the attributes, the "title" and "label" attributes are acceptable to the binder. Also the other attributes ARE present as columns in table "job".
So, post this question in the ASP or Web Development corner of CP.
Cheers
|
|
|
|
|
Hi
i created a dropdownlist that shows all the ((day- label attribute)). by selecting one of those item, it will bind all that selected node's data in a datagrid.
In other words, how can i bind the selected node from the dropdownlist to a datagrid that will bind its attributes?
|
|
|
|
|
Hi all
I want to save my images in XML file and read my XML file and export images from it and show in the .aspx page.
How can i save my images in XML file and how can i export these images and show them in .aspx page?
|
|
|
|
|
Well if you would save the url of the images
in an xml file ...
<?xml version="1.0" encoding="utf-8" ?>
<root>
<img src="Myjpeg1.jpg" />
<img src="Myjpeg2.jpg" />
</root>
You could then add a repeater to aspx
page and set it's data source to the
xml file and then make the itemtemplate like this ...
<ItemTemplate>
<img src='<%# DataBinder.Eval(Container.DataItem, "src") %>'/>
</ItemTemplate>
|
|
|
|
|
XML FILE.....
<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<?xml-stylesheet type="text/css" href="catalog.css"?>
<!DOCTYPE shop SYSTEM "cataloge.dtd">
<!-- . -->
<!-- Avnish Dusara -->
<!-- 12-02-2010 -->
<shop>
<detail>
<shopName>Pc World/Currys</shopName>
<street>Lower High Street</street>
<city>Watford</city>
<postCode>WD25 7DU</postCode>
<telNumber>01923 640 9684</telNumber>
<email>pc.currys@dsg.com</email>
<url>www.pc/currysonline.com</url>
</detail>
<catalog>
<computers>
<computer:packardbell xmlns:computer="http://www.google.ca/">
<computer:itemID>654132</computer:itemID>
<computer:itemName>PACKARD BELL</computer:itemName>
<computer:desc>ALL IN ONE TOUCH SCREEN</computer:desc>
<computer:OS>VISTA</computer:OS>
<computer:cpu>AMD</computer:cpu>
<computer:speed>2.6</computer:speed>
<computer:memory>1GB</computer:memory>
<computer:hdd>250GB</hdd>
<computer:wirelessEnabled>NO</computer:wirelessEnabled>
<computer:quantity>3</computer:quantity>
<computer:price>435.62</computer:price>
</computer:packardbell>
<computer:sony xmlns:computer="http://www.google.ca/">
<computer:itemID>654328</computer:itemID>
<computer:itemName>SONY</computer:itemName>
<computer:desc>UNLTRA SLIM DESKTOP</computer:desc>
<computer:OS>WINDOWS 7</computer:OS>
<computer:cpu>i5</computer:cpu>
<computer:speed>2.1</computer:speed>
<computer:memory>2GB</computer:memory>
<computer:hdd>300GB</computer:hdd>
<computer:wirelessEnabled>YES</computer:wirelessEnabled>
<computer:quantity>8</computer:quantity>
<computer:price>654.65</computer:price>
</computer:sony>
<computer:toshiba xmlns:computer="http://www.google.ca/">
<computer:itemID>123456</computer:itemID>
<computer:itemName>TOSHIBA</computer:itemName>
<computer:desc>POWER AND PERFORMANCE</computer:desc>
<computer:OS>XP</computer:OS>
<computer:cpu>i3</computer:cpu>
<computer:speed>1.3</computer:speed>
<computer:memory>3GB</computer:memory>
<computer:hdd>500GB</computer:hdd>
<computer:wirelessEnabled>NO</computer:wirelessEnabled>
<computer:quantity>12</computer:quantity>
<computer:price>123.32</computer:price>
</computer:toshiba>
<computer:HP xmlns:computer="http://www.google.ca/">>
<computer:itemID>654987</computer:itemID>
<computer:itemName>HP</computer:itemName>
<computer:desc>HOME MOBILE USE</computer:desc>
<computer:OS>WINDOWS 98</computer:OS>
<computer:cpu>i7</computer:cpu>
<computer:speed>1.1</computer:speed>
<computermemory>4GB</computer:memory>
<compute:rhdd>1TB</computer:hdd>
<computer:wirelessEnabled>YES</computer:wirelessEnabled>
<computer:quantity>20</computer:quantity>
<computer:price>789.65</computer:price>
</computer:HP>
</computers>
<homeappliances>
<washingMachine:Bosch xmlns:washingMachine="http://www.google.ca/">>
<washingMachine:itemNumber>986336</washingMachine:itemNumber>
<washingMachine:itemName>Bosch</washingMachine:itemName>
<washingMachine:desc>Fast Cycle</washingMachine:desc>
<washingMachine:color>Pink</washingMachine:color>
<washingMachine:quantity>3</washingMachine:quantity>
<washingMachine:price>236.10</washingMachine:price>
</washingMachine>
<washingMachine:Hot_Point xmlns:washingMachine="http://www.google.ca/">>
<washingMachine:itemNumber>741741</washingMachine:itemNumber>
<washingMachine:itemName>Hot Point</washingMachine:itemName>
<washingMachine:desc>Auto Rinse</washingMachine:desc>
<washingMachine:color>Rainbow</washingMachine:color>
<washingMachine:quantity>6</washingMachine:quantity>
<washingMachine:price>321.65</washingMachine:price>
</washingMachine>
<television:Panasonic xmlns:televison="http://www.google.ca/">>
<television:itemNumber>852852</television:itemNumber>
<television:itemName>Panasonic</television:itemName>
<television:desc>Plasma</television:desc>
<television:size>32'</television:size>
<television:quantity>4</television:quantity>
<television:price>469.45</television:price>
</television:Panasonic>
<television:lg xmlns:televison="http://www.google.ca/">>
<television:itemNumber>963852</television:itemNumber>
<television:itemName>LG</television:itemName>
<television:desc>LED</television:desc>
<television:size>42'</television:size>
<television:quantity>9</television:quantity>
<television:price>987.65</television:price>
</television:lg>
<vacuumeCleaner:Dyson xmlns:vacuumeCleaner="http://www.google.ca/">>
<vacuumeCleaner:itemNumber>963741</vacuumeCleaner:itemNumber>
<vacuumeCleaner:itemName>Dyson</vacuumeCleaner:itemName>
<vacuumeCleaner:desc>Cyclone Function</vacuumeCleaner:desc>
<vacuumeCleaner:bagRefrence>No</vacuumeCleaner:bagRefrence>
<vacuumeCleaner:quantity>2</vacuumeCleaner:quantity>
<vacuumeCleaner:price>65.48</vacuumeCleaner:price>
</vacuumeCleaner:Dyson>
<vacuumeCleaner:Henry xmlns:vacuumeCleaner="http://www.google.ca/">>
<vacuumeCleaner:itemNumber>852741</vacuumeCleaner:itemNumber>
<vacuumeCleaner:itemName>Henry</vacuumeCleaner:itemName>
<vacuumeCleaner:desc>Old Fashion</vacuumeCleaner:desc>
<vacuumeCleaner:bagRefrence>Yes</vacuumeCleaner:bagRefrence>
<vacuumeCleaner:quantity>5</vacuumeCleaner:quantity>
<vacuumeCleaner:price>67.32</vacuumeCleaner:price>
</vacuumeCleaner>
<microwave:Cannon xmlns:microwave= "http://www.google.ca/">>
<microwave:itemNumber>741159</microwave:itemNumber>
<microwave:itemName>Cannon</microwave:itemName>
<microwave:desc>Electrical and Simple</microwave:desc>
<microwave:quantity>8</microwave:quantity>
<microwave:price>50.99</microwave:price>
</microwave:Cannon>
<microwave:Kenwood xmlns:microwave= "http://www.google.ca/">>>
<microwave:itemNumber>986256</microwave:itemNumber>
<microwave:itemName>Kenwood</microwave:itemName>
<microwave:desc>Gas and Complex</microwave:desc>
<microwave:quantity>4</microwave:quantity>
<microwave:price>197.99</microwave:price>
</microwave:Kenwood>
</homeappliances>
</catalog>
</shop>
DTD CODE.....
<!--
New Perspectives on XML
Tutorial 3
Case Problem 1
PBA team roster DTD
Author: Avnish Dusara
Date: 26 Feb 2010
Filename: teams.dtd
Supporting Files:
-->
<!ELEMENT shop (detail*, catalog*)>
<!ELEMENT detail (myLogo, shopName, street, city, postCode, telNumber, email, url)>
<!ELEMENT shopName (#PCDATA)>
<!ELEMENT street (#PCDATA)>
<!ELEMENT city (#PCDATA)>
<!ELEMENT postcode (#PCDATA)>
<!ELEMENT telnumber (#PCDATA)>
<!ELEMENT e-mail (#PCDATA)>
<!ELEMENT url (#PCDATA)>
<!ELEMENT catalog (computers, homeappliances)>
<!ELEMENT computers (computer+)>
<!ELEMENT computer (itemID, itemName, desc, os, cpu, speed, memory, hdd, wirelessEnabled, quantity, price)>
<!ATTLIST computer type CDATA #REQUIRED>
<!ELEMENT itemID (#PCDATA)>
<!ELEMENT itemName (#PCDATA)>
<!ELEMENT desc (#PCDATA)>
<!ELEMENT os (#PCDATA)>
<!ELEMENT cpu (#PCDATA)>
<!ELEMENT speed (#PCDATA)>
<!ELEMENT memory (#PCDATA)>
<!ELEMENT hdd (#PCDATA)>
<!ELEMENT wirelessEnabled (#PCDATA)>
<!ELEMENT quantity (#PCDATA)>
<!ELEMENT price (#PCDATA)>
<!ELEMENT homeappliances (washingMachine*, television*, vacuumeCleaner*, microwave*)>
<!ELEMENT washingMachine (itemNumber, itemName, desc, color, quantity, price)>
<!ELEMENT itemNumber (#PCDATA)>
<!ELEMENT itemName (#PCDATA)>
<!ELEMENT desc (#PCDATA)>
<!ELEMENT color (#PCDATA)>
<!ELEMENT quantity (#PCDATA)>
<!ELEMENT price (#PCDATA)>
<!ELEMENT television (itemNumber, itemName, desc, size, quantity, price)>
<!ELEMENT itemNumber (#PCDATA)>
<!ELEMENT itemName (#PCDATA)>
<!ELEMENT desc (#PCDATA)>
<!ELEMENT size (#PCDATA)>
<!ELEMENT quantity (#PCDATA)>
<!ELEMENT price (#PCDATA)>
<!ELEMENT vacuumCleaner (itemNumber, itemName, desc, bagReference, quantity, price)>
<!ELEMENT itemNumber (#PCDATA)>
<!ELEMENT itemName (#PCDATA)>
<!ELEMENT desc (#PCDATA)>
<!ELEMENT bagReference (#PCDATA)>
<!ELEMENT quantity (#PCDATA)>
<!ELEMENT price (#PCDATA)>
<!ELEMENT microwave (itemNumber, itemName, desc, color, quantity, price)>
<!ELEMENT itemNumber (#PCDATA)>
<!ELEMENT itemName (#PCDATA)>
<!ELEMENT desc (#PCDATA)>
<!ELEMENT quantity (#PCDATA)>
<!ELEMENT price (#PCDATA)>
Basically the top xml is a inventory for a company named tiger direct which im sure you have all heard of and the dtd is a link to that xml. Please ignore small things like google.ca as the url indicator for the namespacing. but they dont link because the dtd is done wrong. can someone please tell me where i went wrong?
Cheers !
|
|
|
|
|
Oh dear….where should we start…
Firstly - the namespacing…that's not going to help, because DTDs don't understand namespaces at all.
Second, that XML cannot be valid - you have tags names things like 'packardbell' and 'sony' - they aren't tag names, they should be part of the data…
Anyway - here's (I think) what the first computer element should look like:
<computer type="you need to put something here... - desktop?">
<itemID>654132</itemID>
<itemName>PACKARD BELL</itemName>
<desc>ALL IN ONE TOUCH SCREEN</desc>
<OS>VISTA</OS>
<cpu>AMD</cpu>
<speed>2.6</speed>
<memory>1GB</memory>
<hdd>250GB</hdd>
<wirelessEnabled>NO</wirelessEnabled>
<quantity>3</quantity>
<price>435.62</price>
</computer>
You'll note that the element is now correctly named 'computer' and namespacing has been removed. Similar changes need to be made to all the computer and home appliance elements.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
CodeProject MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
hey thanks so much for your reply and time to help me out.
I actually did it liek this before.....
<computer type="desktop">
<itemID>654132</itemID>
<itemName>PACKARD BELL</itemName>
<desc>ALL IN ONE TOUCH SCREEN</desc>
<OS>VISTA</OS>
<cpu>AMD</cpu>
<speed>2.6</speed>
<memory>1GB</memory>
<hdd>250GB</hdd>
<wirelessEnabled>NO</wirelessEnabled>
<quantity>3</quantity>
<price>435.62</price>
</computer>
my XML is working just fine its the .dtd that doesn't complie as it should.
|
|
|
|
|
by the way so if i have name spacing, i dont include those elements in the DTD?
|
|
|
|
|
Ummm - you have lots of issues with the DTD as well. You've got lots of repeated elements (itemName and itemNumber, for example). The element names in the definition of the content of the detail element don't match the element naems defined in the DTD (postCode vs postcode, for example).
And remember, the XML is NOT fine if it doesn't validate against the DTD...
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
CodeProject MVP for 2010 - who'd'a thunk it!
|
|
|
|
|
Hi,
I have a xml file that define the path and image to a Video Player .You can see it on www.gogurugo.com/SiteInfo.aspx?id=Ap
Click on any thumbnail and it goes to www.gogurugo.com/Video.aspx
but when we select next time another thumbnail it does not update xml file with current Video.
Everybody please see the site,all of you will understand my problem,Use Internet Explorer and also use Mozila FireFox.
You will see the problem.
Please help me how can i solve this issue?
Thanks
VD
|
|
|
|
|
Now I Know how work XML and XSLT, and if the output is HTML I hav´nt any problem, but I want to generate a new XML file starting from other XML file with the modifications stablished in a XSLT stylesheet, and my question is:
Which is the central object in Visual Studio 2005 whis is able of charging the original XML file apply the transformations contained in the XSLT file and save the result in the new XML File.
Best Regards
|
|
|
|
|
I've just found by myself, the object is an instance of the class XslCompiledTransform whicn enables all the process.
regards
|
|
|
|
|