|
Set OutputXMLFile = fso.CreateTextFile(@"c:\xx.htm",true);
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
Hi
I've just started using DataDynamics ActiveReports for NET which I find very good. However, I'm a bit lost on accessing datasets using XPATH.
Note that I do not want to make my dataset relations nested, and quite often a dataset will contain more than one non-related data table.
Say I have a dataset (dsContracts) with tables/fields as follows
Table - Contracts
Fields - ContractID, Seller, Buyer, Commodity
Table - Details
Fields - ContractID, DetailsID, Grade, Price
Table - Invoices
Fields - ContractID, Invoice, Nett
and that all three tables are related by field ContractID.
I create an xml file by ds.WriteXml("c:\Contracts.xml",WriteSchema)
I would have thought that if I wanted to access dsContracts.Details.Grade the xpath query would be Details/Grade but this is not working.
Could someone give me a clue as to how to access the fields in dataset??
Many thanks in advance
Jeremy Holt
|
|
|
|
|
First of all: you don't use XPath on an XML-Schema, but on the XML file (which can be validated against the Schema).
Now the answer
If the nodeName of your documentElement is Details then it should work. If it's not there are (at least) 2 ways to make it work.
1. Provide the full path: "documentElementNodeName/.../Details/Grade".
Replace "documentElementNodeName" with the actual name of your documentElement and "..." with all elements (if any) till the Details element.
2. Use "//Details/Grade". This finds any Grade element which has a Details parentNode.
|
|
|
|
|
Many thanks your reply - but I still can't get my head around it. I was using the XPath on the XML file.
I wrote a small form to test the expressions using an example in the Help files.
The xsd looks like this (obviously I'm actually accessing the data in the xml).
Using the form below:
/ returns everything as one long string
/* returns only table Images
//* returns everything split into lines
//Journal returns nothing
//Journal/Amount returns nothing
Maybe the code for ProcessFile is wrong ?
Many thanks for your help
Jeremy
<xs:schema id="dsJFinancials" targetNamespace="http://www.tempuri.org/dsJFinancials.xsd" xmlns:mstns="http://www.tempuri.org/dsJFinancials.xsd" xmlns="http://www.tempuri.org/dsJFinancials.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" attributeFormDefault="qualified" elementFormDefault="qualified">
- <xs:element name="dsJFinancials" msdata:IsDataSet="true">
- <xs:complexType>
- <xs:choice maxOccurs="unbounded">
- <xs:element name="Images">
- <xs:complexType>
- <xs:sequence>
<xs:element name="Beneficiary" type="xs:int" />
<xs:element name="Image" type="xs:base64Binary" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
- <xs:element name="Journal">
- <xs:complexType>
- <xs:sequence>
<xs:element name="JournalID" type="xs:int" />
<xs:element name="Cno" type="xs:string" minOccurs="0" />
<xs:element name="Ino" type="xs:int" minOccurs="0" />
<xs:element name="BankCodeID" type="xs:int" minOccurs="0" />
<xs:element name="ChargeCustID" type="xs:int" minOccurs="0" />
<xs:element name="Cheque" type="xs:string" minOccurs="0" />
<xs:element name="Date" type="xs:dateTime" />
<xs:element name="IsFullyPaid" type="xs:boolean" />
<xs:element name="Idnote" type="xs:string" minOccurs="0" />
<xs:element name="Nett" type="xs:decimal" />
<xs:element name="VATAmount" msdata:ReadOnly="true" type="xs:decimal" minOccurs="0" />
<xs:element name="PaidTno" type="xs:int" minOccurs="0" />
<xs:element name="IsPrinted" type="xs:boolean" minOccurs="0" />
<xs:element name="ReceivedDate" type="xs:dateTime" minOccurs="0" />
<xs:element name="IsReconciled" type="xs:boolean" />
<xs:element name="Notes" type="xs:string" minOccurs="0" />
<xs:element name="UserInitials" type="xs:string" />
<xs:element name="UserLocation" type="xs:string" />
<xs:element name="VATRate" type="xs:decimal" />
<xs:element name="BankReference" type="xs:string" minOccurs="0" />
<xs:element name="DbCurr" msdata:ReadOnly="true" type="xs:string" minOccurs="0" />
<xs:element name="CrCurr" msdata:ReadOnly="true" type="xs:string" minOccurs="0" />
<xs:element name="Amount" msdata:ReadOnly="true" type="xs:decimal" minOccurs="0" />
<xs:element name="ExRate" type="xs:decimal" minOccurs="0" />
<xs:element name="LookupRate" msdata:ReadOnly="true" type="xs:decimal" minOccurs="0" />
<xs:element name="AccountID" msdata:ReadOnly="true" type="xs:int" minOccurs="0" />
<xs:element name="ContraAccountID" msdata:ReadOnly="true" type="xs:int" minOccurs="0" />
<xs:element name="DebitID" type="xs:int" />
<xs:element name="CreditID" type="xs:int" />
<xs:element name="ConvertRate" msdata:ReadOnly="true" type="xs:boolean" minOccurs="0" />
<xs:element name="DebitAmount" msdata:ReadOnly="true" type="xs:decimal" minOccurs="0" />
<xs:element name="CreditAmount" msdata:ReadOnly="true" type="xs:decimal" minOccurs="0" />
<xs:element name="IsBankToBank" msdata:ReadOnly="true" type="xs:boolean" minOccurs="0" />
<xs:element name="DebitGroupID" msdata:ReadOnly="true" type="xs:int" minOccurs="0" />
<xs:element name="CreditGroupID" msdata:ReadOnly="true" type="xs:int" minOccurs="0" />
<xs:element name="ContraGroupID" msdata:ReadOnly="true" type="xs:int" minOccurs="0" />
<xs:element name="ContraCurrency" msdata:ReadOnly="true" type="xs:string" minOccurs="0" />
<xs:element name="ContraAccountDescription" type="xs:string" minOccurs="0" />
<xs:element name="AccountDescription" type="xs:string" minOccurs="0" />
<xs:element name="RunningBalance" type="xs:decimal" minOccurs="0" />
<xs:element name="DaysUnpaidText" type="xs:string" minOccurs="0" />
<xs:element name="DaysUnpaid" type="xs:int" minOccurs="0" />
<xs:element name="USDAmount" type="xs:decimal" minOccurs="0" />
<xs:element name="USDExRate" type="xs:decimal" minOccurs="0" />
<xs:element name="Reference" type="xs:string" minOccurs="0" />
<xs:element name="MonthDate" type="xs:dateTime" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
- <Journal>
<JournalID>33993</JournalID>
<Cno>KK041085</Cno>
<Ino>90777</Ino>
<Date>2003-08-24T00:00:00.0000000-03:00</Date>
<IsFullyPaid>false</IsFullyPaid>
<Idnote>D</Idnote>
<Nett>63930.0000</Nett>
<VATAmount>0</VATAmount>
<PaidTno>0</PaidTno>
<IsReconciled>false</IsReconciled>
<UserInitials>JH</UserInitials>
<UserLocation>B</UserLocation>
<VATRate>0</VATRate>
<DbCurr>$</DbCurr>
<CrCurr>$</CrCurr>
<Amount>63930.0000</Amount>
<LookupRate>1.00000000</LookupRate>
<AccountID>198</AccountID>
<ContraAccountID>712</ContraAccountID>
<DebitID>198</DebitID>
<CreditID>712</CreditID>
<ConvertRate>false</ConvertRate>
<DebitAmount>63930.000000000000</DebitAmount>
<CreditAmount>0</CreditAmount>
<IsBankToBank>false</IsBankToBank>
<DebitGroupID>13</DebitGroupID>
<CreditGroupID>21</CreditGroupID>
<ContraGroupID>21</ContraGroupID>
<ContraCurrency>$</ContraCurrency>
<ContraAccountDescription>Sale of goods</ContraAccountDescription>
<AccountDescription>Company Ltd</AccountDescription>
<RunningBalance>1424917.550000000000</RunningBalance>
<USDAmount>63930.000000000000</USDAmount>
<USDExRate>1</USDExRate>
<Reference>024158.001/024158.000</Reference>
<MonthDate>2003-08-01T00:00:00.0000000-03:00</MonthDate>
</Journal>
Public Class frmXPath
Inherits System.Windows.Forms.Form
Private _xp As Xml.XmlDataDocument
Private _nav As XPathNavigator
Private Property XPDoc() As Xml.XmlDataDocument
Get
Return _xp
End Get
Set(ByVal Value As Xml.XmlDataDocument)
_xp = Value
_nav = Value.CreateNavigator
End Set
End Property
Private ReadOnly Property Nav() As XPathNavigator
Get
Return _nav
End Get
End Property
Private Sub frmXPath_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim ds As New dsJFinancials
ds.ReadXml("c:\VSReports\dsFinancials.xml")
Me.XPDoc = New Xml.XmlDataDocument(ds)
End Sub
Private Sub ProcessFile()
Try
Dim expr As XPathExpression = Me.Nav.Compile(Me.txtExpression.Text)
Dim iterator As XPathNodeIterator = Me.Nav.Select(expr)
Dim sb As New System.Text.StringBuilder
While iterator.MoveNext
Dim nav2 As XPathNavigator = iterator.Current.Clone
nav2.MoveToFirstChild()
sb.Append(String.Format("{0} {1}", nav2.Value, nav2.Name))
sb.Append(vbCrLf)
End While
Me.txtOutput.Text = sb.ToString
Catch ex As XPathException
MessageBox.Show(ex.Message)
End Try
End Sub
Private Sub btnOK_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnOK.Click
Me.ProcessFile()
End Sub
End Class
|
|
|
|
|
I've tested your XML in XMLSPY (and MSXML4) and tried the XPath and it returns the correct node.
So I guess it's the ProcessFile function.
Can't help you with that because I don't have VS.NET.
|
|
|
|
|
OK - thanks very much for your help
Jeremy
|
|
|
|
|
Please tell me wat's wrong with the code below
I'd try both way in the asp file to delete the childnode in xml but it couldn't work
*** News.xml ***
-------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<!-- Edited with XML Spy v4.2 -->
<News>
<Article>
<Head>Test 1</Head>
<Des>Testing 123</Des>
<Date>1/9/2003</Date>
</Article>
<Article>
<Head>Test 2</Head>
<Des>Testing 321</Des>
<Date>1/9/2003</Date>
</Article>
</News>
-------------------------------------------------
*** file.asp ***
-------------------------------------------------
<%
If Request.QueryString("Action")="Delete" Then
Dim strID
Dim objXML
Dim subArticle
Dim objLst
Dim subLst
strID = CInt(Request.Form("selectAnnouncement"))
Set objXML = Server.CreateObject("Microsoft.XMLDOM")
objXML.Load(Server.MapPath("News.xml"))
**** 01 ****
Set objLst = objXML.getElementsByTagName("Article")
Set subLst = objLst.item(strID)
objXML.documentElement.removeChild subLst
**** 02 ****
'Set subArticle = objXML.documentElement.childNodes(strID)
'objXML.documentElement.removeChild (subArticle)
Set childNode = Nothing
End If
%>
-------------------------------------------------
|
|
|
|
|
try saving the file...
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
... and replace "Microsoft.XMLDOM" with "MSXML2.DOMDocument"
optionally followed by a version number, like "MSXML2.DOMDocument.4.0"
|
|
|
|
|
I am having trouble using column expressions to return an aggregate of child rows in a typed dataset. Here is my scenario:
I have two tables defined in my xsd schema: Orders and Order Details. The relevant fields are:
Orders
- OrderID (primary key)
- Total (expression column)
OrderDetail
- OrderID (foreign key)
- Qty
- PricePerUnit
- ItemTotal (expression column: Qty*PricePerUnit)
my problem is that when I try to set the expression property of the Total column in "Orders" to "Sum(Child.ItemTotal)" and then run the dataset generator, I get the following error: The custom tool 'MSDataSetGenerator' failed. Unbound reference in the aggregate expression 'Sum(child.[ItemTotal])'
I also get this error when referencing the foreign key constaint name: Sum(Child(FK_Orders2OrderDetails).ItemTotal)"
The MSDN library says that my syntax is correct (look up DataColumn.Expression property)
Any ideas? Thanks
|
|
|
|
|
Does anyone know of a c++ API function that replaces xml forbidden chars (<>&'") with their respective entity references (i.e, replacing the & chars with &amp; entity) ?
|
|
|
|
|
I've written a spirit (http://spirit.sourceforge.net) grammar that does that.
You can download it at http://iobind.sourceforge.net
|
|
|
|
|
i'm new to xml and i'm using the hlep files trying to read an xml document but i can't get it to work. everytime it tries to access anything in the xmldoc it errors with an unhandled exception.
here's my code:
private void button1_Click(object sender, System.EventArgs e)<br />
{<br />
OpenFileDialog1.ShowDialog();<br />
XmlNodeList nodeList;<br />
XmlDocument doc = new XmlDocument();<br />
doc.LoadXml(OpenFileDialog1.FileName);<br />
<br />
XmlNode root = doc.DocumentElement;<br />
nodeList=root.SelectNodes("members");<br />
<br />
foreach (XmlNode node in nodeList)<br />
{<br />
listBox1.Items.Add(node.Name);<br />
}<br />
}
please help, thanks,
Rob
--
There are 10 kinds of people. Those who understand binary and those who don't. <param name="e" />
<member name="M:Newco.Controls.GroupBoxLine.Dispose(System.Boolean)">
Clean up any resources being used.
<member name="P:Newco.Controls.GroupBoxLine.LineColor">
Specifies the color of the line.
<member name="P:Newco.Controls.GroupBoxLine.TextColor">
Specifies the color of the text.
please help, thanks,
Rob
--
There are 10 kinds of people. Those who understand binary and those who don't.
|
|
|
|
|
stupid thing posted when i hit the 'preview' button. here's the xml source:
<?xml version="1.0"?>
<doc>
<assembly>
<name>Newco.Controls</name>
</assembly>
<members>
<member name="T:Newco.Controls.GroupBoxLineDesigner">
<summary>
Summary description for GroupBoxLine.
</summary>
</member>
<member name="M:Newco.Controls.GroupBoxLineDesigner.PostFilterProperties(System.Collections.IDictionary)">
<summary>
Removes the 'FlatStyle' property for this item.
</summary>
<param name="id"></param>
</member>
<member name="M:Newco.Controls.GroupBoxLineDesigner.OnPaintAdornments(System.Windows.Forms.PaintEventArgs)">
<summary>
Draws a light dashed line around the control in design view to make it more visible.
</summary>
<param name="pe"></param>
</member>
<member name="T:Newco.Controls.GroupBoxLine">
<summary>
Custom control to mirror the look of an Office 2003 groupBox.
</summary>
</member>
<member name="F:Newco.Controls.GroupBoxLine.lineColor">
<summary>
Specifies the color of the line.
</summary>
</member>
<member name="F:Newco.Controls.GroupBoxLine.textColor">
<summary>
Specifies the color of the text.
</summary>
</member>
<member name="M:Newco.Controls.GroupBoxLine.#ctor">
<summary>
Default contructor for the class GroupBoxLine.
</summary>
</member>
<member name="M:Newco.Controls.GroupBoxLine.OnPaint(System.Windows.Forms.PaintEventArgs)">
<summary>
Overrides the OnPaint event to create the look of Office 2003.
</summary>
<param name="e"></param>
</member>
<member name="M:Newco.Controls.GroupBoxLine.Dispose(System.Boolean)">
<summary>
Clean up any resources being used.
</summary>
</member>
<member name="P:Newco.Controls.GroupBoxLine.LineColor">
<summary>
Specifies the color of the line.
</summary>
</member>
<member name="P:Newco.Controls.GroupBoxLine.TextColor">
<summary>
Specifies the color of the text.
</summary>
</member>
</members>
</doc>
--
There are 10 kinds of people. Those who understand binary and those who don't.
|
|
|
|
|
LoadXml expects the string to be the XML
you should be using Load(filename)
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
MindNets
“MindNets” is an organization that is being established for providing support and solution in different fields of IT/Computer Science.
Our Expertise includes:
Web Design and Development, Databases, Networks, Desktop Applications, Business Applications, Image Processing, Biometrics, Science and Engineering.
For Students:
During our final projects, we found that there is very little guidance for students; in working on their projects (software) using latest tools and technologies. This is where the whole idea came to our mind and became the basis of “MindNets”.
For Companies:
In this era, for each and every organization; it’s necessary to transfer its business online. This is so, because it not only helps in expanding the business but also in providing more facilities to the customers.
For this we are providing complete web site design, development and hosting facilities. We are also looking forward to facilitate these companies in building and maintaining efficient LAN/WAN networks.
So feel free to contact us at any time; you need us; as we are to help YOU.
Team:
Khurram Ishtiaq Qazi (Netsol)
(c++, visual c++, java, Oracle 8i, (sql/plsql, Developer6))
Asim Nazir (XavorInt)
(c++, java, visual c#, ASP.NET, Sqlserver 2000, Crystal Reports)
Irfan Yousaf (ICBCS)
(VB6, ASP, VB.NET, ASP.NET, Oracle, Visual C++, Visual Prolog)
Mohsin Ali (TWE)
(Microsoft Certified Solution Developer (MCSD), VB6, Flash)
Aamir Alla-u-Din (Operation Al-Badar)
(Microsoft Certified System Engineer (MCSE NT+2000), CCNA)
Contact:
Mail: mind_nets@yahoo.com
Voice: 0333-4294413
MindNets
|
|
|
|
|
Okay i just upgraded from vs.net 2002 to vs.net 2003 and this error comes up. It worked fine before the upgrade but now this error can someone please help. I even did some error testing i can pull xml from my machince and i can access the file directly. Ahhhh!! whats the problem? Thanks.
"The underlying connection was closed: Unable to connect to the remote server. "
Line 69: {
Line 70: case 0:
Line 71: dataSet1.ReadXml("http://www.w3schools.com/xml/note.xml");
Line 72: break;
Line 73: case 1:
Source File: c:\inetpub\wwwroot\bc\webform1.aspx.cs Line: 71
Stack Trace:
[WebException: The underlying connection was closed: Unable to connect to the remote server.]
System.Net.HttpWebRequest.CheckFinalStatus()
System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
System.Net.HttpWebRequest.GetResponse()
System.Xml.XmlDownloadManager.GetNonFileStream(Uri uri, ICredentials credentials)
System.Xml.XmlDownloadManager.GetStream(Uri uri, ICredentials credentials) +94
System.Xml.XmlUrlResolver.GetEntity(Uri absoluteUri, String role, Type ofObjectToReturn) +55
System.Xml.XmlTextReader.CreateScanner() +384
System.Xml.XmlTextReader.Init() +23
System.Xml.XmlTextReader.Read() +530
System.Xml.XmlReader.MoveToContent() +75
System.Data.DataSet.ReadXml(XmlReader reader, Boolean denyResolving) +145
System.Data.DataSet.ReadXml(String fileName) +63
BC.WebForm1.Button1_Click(Object sender, EventArgs e) in c:\inetpub\wwwroot\bc\webform1.aspx.cs:71
System.Web.UI.WebControls.Button.onclick(EventArgs e)
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
System.Web.UI.Page.ProcessRequestMain() +1277
Da Intern
|
|
|
|
|
Are you saying that you can access http://www.w3schools.com/xml/note.xml from a browser, but not your ASPX page?
- Mike
|
|
|
|
|
exactly, do you have some ideas
Da Intern
|
|
|
|
|
I have an XML document that in some elements can contain HTML. The document is being sent to a client app via a web service. The HTML contained in the document can contain images. The images have document delative Urls. I want to add the complete url to the image tag. Is there an easy way to do this? I have tried using a regex but have been unable to get it to work. Thanks.
Steve
Not all who wander are lost...
|
|
|
|
|
Hi im trying to use this line of code to create an xml file but it just overwrites it every time or appends to the wrong part. I have tried changing the bool to true and false also tried changing write to writeline nothing works please help.
using (StreamWriter sw = new StreamWriter("TestFile.xml"))
{
sw.Write("<DispatcherQ>" + "<Dispatcher> " + DispID.Text + "</Dispatcher>" + "<CustomerInfo> " + listBox2.SelectedItem.ToString() + "</CustomerInfo>" + "<TaxiInfo> " +listBox3.SelectedItem.ToString()+ "</TaxiInfo>" + "</DispatcherQ>" );
}
Thanks alot,
Da Intern
|
|
|
|
|
Hi
Isn´t XmlTextWriter a better choice?
in VB
Dim wrtXMLWriter As New XmlTextWriter("TestFile.xml", Nothing)
and use .WriteRaw or any other XmlTextWriter-method that works for your purposes.
Regards
Daniel
|
|
|
|
|
okay but i want it to create a new set of elements like this: when i click this button it creates the xml file and the first element then when i click it again it adds the new elements to that xml file.
Da Intern
|
|
|
|
|
You can use XmlDocument.CreateElement and .AppendChild to add your information to your document.
in c++
given that Child,Name,TopElement all are XmlElements
sData is the content, the info in the element;
ChildElement = doc->CreateElement("tagname");
TopElement->AppendChild(ChildElement);
NameElement = doc->CreateElement("tagname");
NameElement->InnerText = sData;
ChildElement->AppendChild(NameElement);
.. or something like that
I guess you have to check in the button_click function if you already have pressed the button and if not -> create a new xmldokument
Regards
Daniel
|
|
|
|
|
Anyone know where to find one? I'm too lazy to make one;) just wanted the news on my site...
// Steve McLenithan
Family Guy: Season 2 - Episode 8
|
|
|
|