|
I am sure you can find existing articles on the internet discussing all the issues in comparing the two so I won't attempt to reinvent the wheel here. Try using Google.
That said, one significant benefit in many cases is that a Schema file is XML where a DTD is not. This fact has many repercussions that you can find out all about if you study XML technology.
led mike
|
|
|
|
|
XML:
<autostartjobs>
<job>DbRemote<job>;
<job>License<job>;
<job>UploadFile<job>;
<job>DownloadFile<job>;
<autostartjobs>;
C# Code:
List<string> AutostartJobsStringList = new List<string>();
foreach (XmlNode AutostartNode in kindknoop.ChildNodes)
{
if (AutostartNode.Name== "Job")
AutostartJobsStringList.Add(kindknoop.Value);
}
Output:
AutostartJobsStringList[0] == DbRemoteLicenseUploadFileDownloadFile
AutostartJobsStringList[1] == DbRemoteLicenseUploadFileDownloadFile
AutostartJobsStringList[2] == DbRemoteLicenseUploadFileDownloadFile
AutostartJobsStringList[3] == DbRemoteLicenseUploadFileDownloadFile
Preferred output:
AutostartJobsStringList[0] == DbRemote
AutostartJobsStringList[1] == License
AutostartJobsStringList[2] == UploadFile
AutostartJobsStringList[3] == DownloadFile
Question: What am i doing wrong? How can i get the preffered output?
|
|
|
|
|
Your problem does not appear to have anything to do with XML.
MegaBlasterX wrote: foreach (XmlNode AutostartNode in kindknoop.ChildNodes)
{
if (AutostartNode.Name== "Job")
AutostartJobsStringList.Add(kindknoop.Value);
}
led mike
|
|
|
|
|
foreach (XmlNode AutostartNode in kindknoop.ChildNodes)
{
if (AutostartNode.Name== "Job")
AutostartJobsStringList.Add(AutostartNode.InnerText);
}
|
|
|
|
|
I am programming a movie info collect tool. I think store all data with XML is OK.
Here is the MovieDataXML
<?xml version="1.0" encoding="utf-8" ?>
<Data>
<Movie>
<ChineseName>aa</ChineseName>
<EnglishName>aa</EnglishName>
<Year>aa</Year>
<Area>aa</Area>
<Type>aa</Type>
<Language>aa</Language>
<Subtitle>aa</Subtitle>
<IMDB>aa</IMDB>
<Resolution>aa</Resolution>
<Director>aa</Director>
<Actors>aa</Actors>
<Introduction>aa</Introduction>
<BelongTo>aa</BelongTo>
<DiscNumber>aa</DiscNumber>
</Movie>
</Data>
And when I try to read the data.
ClassXMLHandler clsXmlHandler = new ClassXMLHandler();
string strMovieData = "Data";
XmlNode xNodeMovieData = clsXmlHandler.MovieDataDocument.SelectSingleNode(strMovieData);
XmlNodeReader xReader = new XmlNodeReader(xNodeMovieData);
Here is the problem
If I read XML data by DataTable
There will be a Exception "DataTable does not support schema inference from Xml",
If I create this DataTable schema manually,there is no data in that DataTable.
DataTable dtMovieData = new DataTable();
dtMovieData.ReadXml(xReader);
But I found it is OK if I use DataSet instead of DataTable
DataSet ds = new DataSet();
ds.ReadXml(xReader);
I don't know why.
|
|
|
|
|
Hi,
I have a XML element called book. I just have to specify the <xs:pattern xmlns:xs="#unknown"> for that element. The book element should have "steps" word with in it. That is the pattern that I need to implement but don't have any idea. Any one of you have any idea then please help me.
Either you love IT or leave IT...
|
|
|
|
|
Hi All,
Is there any way to use xs:Pattern expression like SQL "like" statement.
Either you love IT or leave IT...
|
|
|
|
|
Hi,
I have a xml file that through it I making an xslt with a format of a word document I generate.
In the word document I see the letters "<" or ">". I want to see "<" and ">" instead of it.
Is there any line I have to write in the xslt file or in the xml file in order to enable it ?
What is the line that I have to write and where (in the xml or xslt) ?
thanks, Ido
|
|
|
|
|
idoyohanan wrote: "<" or ">". I want to see "<" and ">" instead of it.
they are equal??
|
|
|
|
|
Can somebody tell me how to handle fixing XML validation errors?
In my code, I call
xmlDoc.Validate(Schemas_ValidationEventHandler);
in my main method to validate the Xml document that I have just created.
This calls the below eventhandler for each validation error. Based on the error type, i want to be able to perform various actions on the problematic node (example: delete the node)
static void Schemas_ValidationEventHandler(object sender, ValidationEventArgs e) {
System.Xml.Schema.XmlSchemaValidationException ex = (XmlSchemaValidationException)e.Exception;
//I want to delete the node 'ex.SourceObject' if the content is empty.
//How do I get the document node?? }
|
|
|
|
|
|
Below is what I did to be able to delete problematic elements(does not conform to schema) from an XML file.
1. In the event handler, I set the innertext of error nodes to 'ERROR'
static void Schemas_ValidationEventHandler(object sender, ValidationEventArgs e)
{
//Get the Schema Validation Exception
System.Xml.Schema.XmlSchemaValidationException ex = (XmlSchemaValidationException)e.Exception;
//Get the error Xml Node
XmlNode node = (XmlNode)ex.SourceObject;
//Set the text to ERROR so that it can be removed later
//NOTE: trying to delete error nodes here as part of validation causes the validation to break
//that is why i used this method of marking problematic nodes and removing them later
node.InnerText = "ERROR";
}
2. Then I have a method to remove 'ERROR' nodes. This method along with the Validate() method is called in a loop until there are no more ERROR nodes. The resulting XML document is a document conforming to its schema with all other error nodes deleted.
static bool RemoveErrorNodes(XmlDocument xmlDoc)
{
bool deletedNodes = false;
XPathNavigator xpath = xmlDoc.CreateNavigator();
XPathNodeIterator errNodes = xpath.Select("//*");
while (errNodes.MoveNext())
{
XPathNodeIterator errNode = errNodes.Current.Select("*[text()='ERROR']");
while (errNode.MoveNext())
{
errNode.Current.DeleteSelf();
deletedNodes = true;
}
}
return deletedNodes;
}
|
|
|
|
|
hai..
I have a object like as below.. which is a FreeThreadedDOMDocument old version
Dim xslDoc As MSXML2.FreeThreadedDOMDocument
now i am just upgrading to FreeThreadedDOMDocument60 for that i have written
Dim xslDoc As MSXML2.FreeThreadedDOMDocument60
there after am having the line of code like this
xslDoc.loadXML STR_XSL1
xslDoc.selectSingleNode(STR_XPATH_PRIORITY_SORTORDER).nodeValue = " "
am getting error like object variable or with block variable not set ..if i use FreeThreadeddomdocument60..
if not used it then its working fine..
thanks in advance if any one come with answer..
Chandu
|
|
|
|
|
m_chandu wrote: FreeThreadedDOMDocument old version
It has been a while since I used MSXML so this is from old memory. Early versions of MSXML implemented pathing syntax ( I think it was called XSL Path or something ) before XPath was approved. Some Later versions added support for the XPath standard, but also maintained backwards compatibility for the original syntax, and defaulted to the using the old syntax.
If your XPath statement contains any of the new XPath features you have to tell the DOM to use the XPath syntax. I think you have to use some generic like method [ .setProperty(.....) or something ] and pass the correct string values to setup the DOM to use XPath.
led mike
|
|
|
|
|
hai led
thanks for giving the reply but i have placed the property even though am getting error what i mentioned above..
below is the total code what i have..
Dim xslDoc As MSXML2.FreeThreadedDOMDocument60
Set xslDoc = New MSXML2.FreeThreadedDOMDocument60
xslDoc.setProperty "SelectionLanguage", "XPath"
xslDoc.setProperty "SelectionNamespaces", "xmlns:xsl='http://www.w3c.org/1999/XSL/Transform'"
xslDoc.setProperty "AllowXsltScript", True
xslDoc.async = False
xslDoc.validateOnParse = False
xslDoc.loadXML strXML
xslDoc.selectSingleNode(STR_XPATH_PRIORITY_SORTORDER).nodeValue = " "
the last line is giving us error if we have FreeThreadedDOMDocument60..
without 60 its working fine..
thanks
chandu.M
|
|
|
|
|
Hi,
I have a simple xml-structure to represent my bookcase.
lib
+ books
+ serie
+ book (aut: type = IDREFS)
- title
- pages
+ authors
+ author (id: type = ID)
- first_name
- last_name
It contains 2 tables, one of the authors identified with id. And a table with the books with an attribute aut pointing to one or more of the authors.
Now i want to show the series, the booktitle and the author(s). The problems is how to show the author and not just the ID in the aut attribute.
I have used a named template to find the author
<xsl:template name="author_name">
<xsl:param name="idref"/>
<xsl:for-each select="//author[@id=$idref]">
<xsl:value-of select="last_name"/>
<xsl:value-of select="first_name"/>
</xsl:for-each>
</xsl:template>
And I'm using it like this
<xsl:call-template name="author_name">
<xsl:with-param name="idref" select="@aut"/>
</xsl:call-template>
And this works, BUT NOT for books written by 2 or more authors. I have tried tokenize but that function is only available in xls 2.0. And then IE has troubles with it.
Any help on this would be appreciated.
Learn from the mistakes of others, you may not live long enough to make them all yourself.
|
|
|
|
|
I am getting this error in soap response. I am consuming java webservice from .net 2005 C# code.
Please help me !! I pasting error below.
thanks in advance.
<soapenv:Body><soapenv:Fault><faultcode></faultcode><faultstring>com.ctc.wstx.exc.WstxEOFException: Unexpected EOF in prolog
at [row,col {unknown-source}]: [1,0]</faultstring><detail /></soapenv:Fault></soapenv:Body>
|
|
|
|
|
The functional requirement is , we hav a table with data in following format..
C1 C2 c3
------------------
A AA1 y
A AAA1 n
B AA1 y
B AAA1 n
C AA1 y
the required output by xslt is
C1 AA1 AAA1
--------------------
A y n
B y y
C y
Can anybody help me out from this issue.
Thanks in advance.
Tarini singh..
Zenta pvt Ltd
|
|
|
|
|
tarun_codeproject wrote: Can anybody help me out from this issue.
Help you with what? You didn't ask a question.
led mike
|
|
|
|
|
Hi
I have written the following asp.net page and creating the xml file through a method everything is fine it is creating the file but i have a problem. May be you can help for that. it is about the xml file output when it created it showing TABLE and TABLE1 as node in xml how i can change it to meaningful name. My Code is as follows. XML file is at the bottom of the code
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Xml;
using System.IO;
public partial class _Default : System.Web.UI.Page
{protected void Page_Load(object sender, EventArgs e){
GetEmployees("London");
}
public static void GetEmployees(string City){
//String sConnection = "server=HTCWEBDEMO;database=hometrust;user id=ht_admin;password=htc_tr!st";
String sConnection = "server=ZAFAR-PC\\SQLEXPRESS;Integrated Security=SSPI;database=northwind";
SqlConnection mySqlConnection = new SqlConnection(sConnection);
mySqlConnection.Open();
// Get the same data through the provider.
//string mySQLStatement = "SELECT Title,FirstName,LastName,PhoneNumber,Faxnumber, email from contactlist where TeamName='" + TeamName +"'; select FirstName, LastName from contactlist where TeamMorty ='True' and teamname='" + TeamName + "';";
string mySQLStatement = "SELECT FirstName,LastName,Title,City from employees where city= '" + City + "';select FirstName, LastName from employees where city='" + City + "';";
//SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter(mySQLStatement, sConnection);
SqlDataAdapter mySqlDataAdapter = new SqlDataAdapter(mySQLStatement, sConnection);
DataSet myDataSet2 = new DataSet();
myDataSet2.DataSetName = "Contacts";
mySqlDataAdapter.Fill(myDataSet2);
// Write data to files: data1.xml and data2.xml for comparison.
myDataSet2.WriteXml("c:/temp/ContactList.xml");
mySqlConnection.Close();
}
}
XML FILE OUTPUT
<?xml version="1.0" standalone="yes" ?>
- <Contacts>
- <Table>
<FirstName>Steven</FirstName>
<LastName>Buchanan</LastName>
<Title>Sales Manager</Title>
<City>London</City>
</Table>
- <Table>
<FirstName>Michael</FirstName>
<LastName>Suyama</LastName>
<Title>Sales Representative</Title>
<City>London</City>
</Table>
- <Table>
<FirstName>Robert</FirstName>
<LastName>King</LastName>
<Title>Sales Representative</Title>
<City>London</City>
</Table>
- <Table>
<FirstName>Anne</FirstName>
<LastName>Dodsworth</LastName>
<Title>Sales Representative</Title>
<City>London</City>
</Table>
- <Table1>
<FirstName>Steven</FirstName>
<LastName>Buchanan</LastName>
</Table1>
- <Table1>
<FirstName>Michael</FirstName>
<LastName>Suyama</LastName>
</Table1>
- <Table1>
<FirstName>Robert</FirstName>
<LastName>King</LastName>
</Table1>
- <Table1>
<FirstName>Anne</FirstName>
<LastName>Dodsworth</LastName>
</Table1>
</Contacts>
|
|
|
|
|
hello everyone..
how can i parse an xml documents and/or how can i convert a doc file to xml file. is this possible??
hope anyone can help me about this...
thanks in advance..
jyn
|
|
|
|
|
jhyn wrote: how can i parse an xml documents
go to www.w3schools.com
they have a tutorial on XML.
jhyn wrote: how can i convert a doc file to xml file. is this possible??
Newer versions of MS Word support saving a document as XML. The latest versions now default to XML. See the thread below about OOXML and WordprocessingML .
led mike
|
|
|
|
|
thank you for your reply
jyn
|
|
|
|
|
Hello.
I work on docx parser. All i need is to extract text and some layout info (such as font name, font size, alignment and so on).
I confront a problem while parsing document's main part (document.xml).
The problem is word division. For some reason Word 2007 sometimes divide words in to different runs.
Example:
"Identifier information about the certificate authority that issued the certificate."
In document.xml it looks like
<w: p w:rsidR="00000000" w:rsidRDefault="00B91456">
<w:pPr>
<w:pStyle w:val="BulletedList" />
<w:numPr>
<w:ilvl w:val="0" />
<w:numId w:val="72" />
</w:numPr>
</w:pPr>
<w:r>
<w:t>Iden</w:t>
</w:r>
<w:r>
<w:t>tifier information about the certificate authority that issued the certificate.</w:t>
</w:r>
</w: p>
The other example:
"The server certificate name specified should match the fully qualified domain name."
In document.xml it looks like
<w: p w:rsidR="00000000" w:rsidRDefault="00B91456">
<w:pPr>
<w:pStyle w:val="Listalerttext" />
<w:framePr w:wrap="notBeside" />
</w:pPr>
<w:r>
<w:t>The server c</w:t>
</w:r>
<w:r>
<w:t>ertificate name specified should match the fully qualified domain name.</w:t>
</w:r>
</w: p>
What is the reason behind this?
And, what is more important, how can I handle this?
Such situation occurs many times and I completely don't no what to do.
Word 2007 somehow handles it, can anyone suggest how?
thanks..
|
|
|
|
|
Member 4083157 wrote: What is the reason behind this?
And, what is more important, how can I handle this?
I don't know, but if I needed to know I might start by reading the documentation[^] rather than typing messages into internet forums.
led mike
|
|
|
|