1 / 11

Programação com XML e XSLT

Programação com XML e XSLT. Web Control XML – System.Web.UI.WebControls.XML Use the Xml control to display the contents of an XML document without formatting or using XSL Transformations. XmlDocument – XslTransform Transformação de um documento XML Display num Web XML control

rasul
Download Presentation

Programação com XML e XSLT

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Programação com XML e XSLT

  2. Web Control XML – System.Web.UI.WebControls.XML • Use the Xml control to display the contents of an XML document without formatting or using XSL Transformations.

  3. XmlDocument – XslTransform • Transformação de um documento XML • Display num Web XML control XmlDocument doc = new XmlDocument(); doc.Load(Server.MapPath("people.xml")); XslTransform trans = new XslTransform(); trans.Load(Server.MapPath("peopletable.xsl")); xml1.Document = doc; xml1.Transform = trans; Exemplo

  4. Preencher DataSet com XML • Método ReadXml • XmlTextReader string pathname=Server.MapPath("produtos.xml"); XmlTextReader tr=new XmlTextReader(pathname); mydataset=new DataSet(); mydataset.ReadXml(tr); DataGrid1.DataSource=mydataset; DataGrid1.DataBind();

  5. Process XML Data In-Memory • Discusses the two models for processing XML data. The XmlDocument class, and its associated classes, is based on the W3C Document Object Model. The XPathDocument class is based on the XPath data model. • http://msdn2.microsoft.com/en-us/library/2bcctyt8.aspx • http://msdn2.microsoft.com/en-us/library/534aacaa.aspx

  6. Migrating from Version 1.1 of the XML Classes  • http://msdn2.microsoft.com/en-us/library/534aacaa.aspx

  7. The XslCompiledTransform class is the new XSLT processor. It replaces the XslTransform class. The XsltSettings enumeration is used to enable optional XSLT settings such as support for embedded scripts or the XSLT document() function. • Version 1.1

  8. Criar XML com informação de um DataSet (1) • Método WriteXml oleDbDataAdapter1.Fill(dataset);  string name=tbName.Text;  string path=Server.MapPath(".");      string filepath=path+"\\ " + name;  dataset.WriteXml(filepath); • Vários overload: DataSet.WriteXml (String) DataSet.WriteXml (XmlWriter, XmlWriteMode) …

  9. Criar XML com informação de um DataSet (2) • Método GetXml do DataSet • Class XPathNavigator • Provides a cursor model for navigating and editing XML data. • Class XPathDocument • Provides a fast, read-only, in-memory representation of an XML document using the XPath data model. string strxml = dataset.GetXml(); StringReader str=new StringReader(strxml); XPathDocument docpath = new XPathDocument(str); XPathNavigator nav=docpath.CreateNavigator(); Xml1.XPathNavigator = nav; Xml1.DataBind();

  10. Actualizar BD com documento XML – (tabela Produtos) string pathname2= Server.MapPath("produtos2.xml");  DataSet novo=new DataSet();  novo.ReadXml(pathname2);  oleDbDataAdapter1.Update(novo,"Produtos");

  11. Transformações XSLT • Class XslCompileTransform • Microsoft .NET Framework XSLT processor. This class is used to compile style sheets and execute XSLT transformations.

More Related