|
Sub DisplayCustomer(ByVal position As Integer)
Dim node As XmlNode = xmlDoc.SelectSingleNode("/Customers/Customer[" & position & "]")
This is VB.NET. What would be the C# equivlient?
I have this so far, pero no function.
void DisplayCustomer(int position)
{
XmlNode node=xmlDoc.SelectSingleNode(@"/Customers/Customer[position]");
/\ |_ E X E GG
|
|
|
|
|
Ok, I have fixed it. For the C# version, all you have to do is replace the "&'s" with "+'s" like this...
BEFORE:
void DisplayCustomer(int position)
{
XmlNode node = xmlDoc.SelectSingleNode("/Customers/Customer[position]");
AFTER:
void DisplayCustomer(int position)
{
XmlNode node = xmlDoc.SelectSingleNode("/Customers/Customer[" + position + "]");
I guess I kinda ignored the fact that the SelectSingleNode parameter is a string. Oh well.
/\ |_ E X E GG
|
|
|
|
|
I heard that it's easier to learn the XML Schemas than it is for the XML DTD, how true is this? Also, does anyone know ehere to find a very detailed tutorial for XS but speaks to the beginner?
Thanks,
Michael Lauzon, Founder
The Quill Society
http://www.quillsociety.org/
mlauzon@quillsociety.org
|
|
|
|
|
|
i have the following tags in an .xsl
<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:js="http://www.netlink.com/schemas">
<xsl:output version="1.0" method="html"
encoding="iso-8859-1" omit-xml-declaration="yes"/>
but when i apply the .xsl to the .xml it generates the following META tag
<META http-equiv="Content-Type" content="text/html; charset=UTF-16">
which causes some problems because of the UTF-16, specifically it doesn't display correctly the accents in a site that is in spanish
any idea why is this tag being inserted even if i have a meta tag in my .xsl
thanks in advance
|
|
|
|
|
Hello, all.
When I try to parse the XML document using SAX reader method "parse" I'm have an error "E_FAIL". Why?
I'm using MSXML4. This is my XML document:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<GetLevelResponse xmlns="http://www.docusync.com/svc">
<GetLevelResult>
<Collection>
<File>
<Name>Test</Name>
<Size>0</Size>
<Created>0001-01-01T00:00:00.0000000+02:00</Created>
<Modified>0001-01-01T00:00:00.0000000+02:00</Modified>
<Version>0</Version>
<TimeStamp>671113</TimeStamp>
<IsDirectory>true</IsDirectory>
<HasChildFolder>true</HasChildFolder>
<Files />
<ID>40</ID>
<StorageType>Root</StorageType>
<PhysicalContainerPath />
</File>
<IsContentRequired>true</IsContentRequired>
<IsCompressed>false</IsCompressed>
<PhysicalRelativePath />
<LogicalRelativePath />
</Collection>
<HasErrors>false</HasErrors>
<ID>0</ID>
<Exceptions />
</GetLevelResult>
</GetLevelResponse>
</soap:Body>
</soap:Envelope>
Help me, please. Thanks.
|
|
|
|
|
I have an XSD schema file that defines data structures for a legacy EDI system (still in use.) As we're moving more and more apps to .Net, and our customers are doing the same, we're adding WebService support for processing transactions currently handled by the EDI systems.
The edi definitions XSD file will be used by applications other than the new WebService, and will provide cross-compatibility for a variety of applications that communicate back and forth by passing this data around.
The XSD that defines valid service requests and responses for the WebService is dependent on the edi definitions in the edi.xsd file. To provide the customer an opportunity to pre-validate transaction requests prior to sending, I have a WebMethod that returns the WebService's XSD file. The problem lies in the fact that the WebService's XSD imports the edi.xsd.
Actually, this isn't much of a problem. It's a simple matter to provide a fully-qualified URL for the schemaLocation in the <xsd:import> element. The real problem lies in the fact that both schema definitions change with some regularity. And at any one time we may have up to four separate versions of each file (dev, test, staging/cust test, production).
My concern lies in this last problem. I'm concerned that if we hard-code the URL of the development edi.xsd schema into the development WebService schema, that someone may forget to change it as the WebService moves up the deployment ladder. It would be a VBT for us to have a production schema that is importing a development schema dependency. One experimental change to the development edi schema could cause the WebService to cease functioning.
I know there have to be other shops that are providing dynamic XSD's with imports to their clients/customers. What's a good tried-and-true method of ensuring that each level of WebService XSD imports the correct version of the edi.xsd?
Is there any way to combine the two schemas on-the-fly, so that the client only has one schema definition to look at, instead of having to find the imported schema?
Alternatively, would it be possible for me to return an XmlSchema object that properly refers to the correct dependency schema(s)? I've looked into the XmlResolver, which may work for this, but I've had no success figuring out how to attach one to an XmlSchema.
I've also considered returning an XmlSchemaCollection containing both schemas, but there's a bug in the framework that prevents an XmlSchemaCollection from being a return type on a WebMethod. Whenever I try to do this, I get an InvalidOperationException.
Any solutions or suggestions are appreciated.
Thanks
Grim (aka Toby) MCDBA, MCSD, MCP+SB
|
|
|
|
|
Hi !
I'm trying to compile expatpp in order to use the same functions as in the testexpatpp2.cpp example file. But it happens that there's some trouble with the OOfile library.
Here is the command line i'm using to compile :
g++ testexpatpp2.cpp ../src_pp/expatpp.o -o testexpatpp2 -I/home/.../XML/src/expatpp/expat/xmlparse/ -I/home/.../XML/src/expatpp/src_pp/ -I/home/.../XML/src/expatpp/oofileBits/ -lexpat
Just to say, the other examples testexpat.c and testexpatpp.cpp are working so the problem is coming from -I/home/.../XML/src/expatpp/oofileBits/ -lexpat
Here is the error i'm getting :
g++ testexpatpp2.cpp ../src_pp/expatpp.o -o testexpatpp2 -I/home/.../XML/src/expatpp/expat/xmlparse/ -I/home/.../XML/src/expatpp/src_pp/ -I/home/.../XML/src/expatpp/oofileBits/ -lexpat
In file included from /home/.../XML/src/expatpp/oofileBits/oof0.h:244,
from /home/.../XML/src/expatpp/oofileBits/oofstr.h:13,
from /home/.../XML/src/expatpp/oofileBits/oofxml.h:11,
from testexpatpp2.cpp:15:
/home/.../XML/src/expatpp/oofileBits/oofbool.h:61: error: redeclaration
of C++ built-in type `bool'
/home/.../XML/src/expatpp/oofileBits/oofbool.h:62: error: parse
error before `false'
/home/.../XML/src/expatpp/oofileBits/oofbool.h:63: error: parse
error before `true'
In file included from /usr/include/c++/3.3/backward/iostream.h:31,
from /home/.../XML/src/expatpp/oofileBits/oofios.h:59,
from /home/.../XML/src/expatpp/oofileBits/oofstr.h:19,
from /home/.../XML/src/expatpp/oofileBits/oofxml.h:11,
from testexpatpp2.cpp:15:
/usr/include/c++/3.3/backward/backward_warning.h:32:2: warning: #warning This file includes at least one deprecated or antiquated header. Please consider using one of the 32 headers found in section 17.4.1.2 of the C++ standard. Examples include substituting the <x> header for the <x.h> header for C++ includes, or <sstream> instead of the deprecated header <strstream.h>. To disable this warning use -Wno-deprecated.
In file included from /home/.../XML/src/expatpp/oofileBits/oofstr.h:19,
from /home/.../XML/src/expatpp/oofileBits/oofxml.h:11,
from testexpatpp2.cpp:15:
/home/.../XML/src/expatpp/oofileBits/oofios.h:71:55: strstream.h: No such file or directory
/home/.../XML/src/expatpp/oofileBits/oofios.h:75:56: io.h: No such file or directory
As far as i understand what's going on it seems that the config has not been well done, if not it won't try to redefine bool like this !
So my question is : what can i do to make it work !
Help !
Merci de votre attention
Olivier
|
|
|
|
|
I have a very simple XML file:
<?xml version="1.0" encoding="utf-8"?>
<Transactions>
<Transaction BoothNum='1' Date='5/22/2004' Time='5:18:02 PM' Quarters='5'/>
<Transaction BoothNum='1' Date='5/22/2004' Time='5:18:25 PM' Quarters='10'/>
</Transactions>
(wierd, the editor is converting the T's to lower case.)
And some very simple code:
XmlDocument doc=new XmlDocument();
doc.Load("transactions.xml");
try
{
XmlNode n=doc.SelectSingleNode("sum(/Transactions/Transaction[@BoothNum='1']/@Quarters)");
...
And I get that stupid error. Why doesn't sum work?
If I call doc.SelectNodes("/Transactions/Transaction[@BoothNum='1']/@Quarters"
) I get two Nodes back!
Thanks!
Marc
|
|
|
|
|
Hi Marc. I think you need to use the Evaluate method of the XPathNavigator class to get the sum value. Something like this:
XmlDocument doc = new XmlDocument();
doc.Load("transactions.xml");
XmlElement root = doc.DocumentElement;
XPathNavigator xpath = root.CreateNavigator();
string expr = "sum(/Transactions/Transaction[@BoothNum='1']/@Quarters)";
int quarterTotal = (int) xpath.Evaluate(expr);
|
|
|
|
|
Mike Ellison wrote:
I think you need to use the Evaluate method of the XPathNavigator class to get the sum value.
Thank you!!! That works!!!
(only minor issue was that the object returned is double. Easily converted to an int).
Marc
Microsoft MVP, Visual C#
MyXaml
MyXaml Blog
|
|
|
|
|
Hi Dear...
I struck in a problem & I know you can help me..
I've a pro-merchant account in amazon..& I want to upload Inventory to amazon.. but getting problem..File Error..even from site upload...
Can you send me Execl file you used for that uploading...
+ if possible some coding snippet of uploading invenorty. I want to upload through coding.. send me at:
sumit_kapoor1980@hotmail.com
or chat with me at hotmail account or yahoo: sumit_kapoor1980@yahoo.com
I hope you will help me..
Thanks
Have a Nice Life..
Sumit Kapoor.
---Sumit Kapoor---
|
|
|
|
|
Hi,
I've come here to ask a question. I'm a fairly new coder and have never worked using XML before (so don't laugh at me ), anyhow, I was wondering how I would go about storing a list type thing in XML, a list that may contain - ID, Title, Value or some sort of information like that. I’m not to sure you’ll understand what I mean let me show you an example (Not to sure if this is right though )
<person>
<name>Mike</person>
<age>23</age>
</person>
<person>
<name>Laura</name>
<age>27</age>
</person>
How could I just list the Names, in the group of person? Also how could I add/remove/edit names within that group? You don't need to explain in detail just give me some clue of the type of thing I need to use.
Oh btw, want to use c# .
Many Thanks,
Richard
|
|
|
|
|
You would use XSL probably to list the names. In C#, you can just search for a node, or a group of nodes, and then grab the text out of them, it's easy enough. Widnows Developers Journal published an article from me and Matthew Cole about a year ago on using XML in C#, with a wrapper class for most of the functionality available.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
That is a malformed xml document!!!!
Check this out. It's a neat video showing how to make a .net GUI and populate a compbox text boxes with the xml data.
You have to see it to beleive it.
Visual Basic At The Movies > Data and XML[^]
Do the "Reading XML Files" one...
It's in VB, but if you I can post the C# that i'm working on.
/\ |_ E X E GG
|
|
|
|
|
Hi,
I'v got the following XML file:
===================================
<folder ID='12' >
<folder ID='34' >
<folder ID='56' >
<page ID='78' />
</folder>
</folder>
</folder>
====================================
I want to select all children of folder with ID='34'
So, one folder element and one page element..
Currently I only managed to select the folder with ID='56', the element 'page' didn't comes back with the selection..
If anyone can help me..
Thanx
|
|
|
|
|
could u please show me the code for that may be i can help u.;P P
|
|
|
|
|
Hi I have this code in C#;
=======================================================
XmlNodeList nodeList;
nodeList=root.SelectSingleNode("descendant::folder[attribute::ID='34']") ;
foreach (XmlNode folderNode in nodeList) {
string nodeValue = folderNode.Attributes["ID"].Value.ToString();
}
=======================================================
this code comes back with a selection of node ID='56' but NOT the '78'
Thanx in advance,
Jack
|
|
|
|
|
1. you will only get one result as you used SelectSingleNode - which is you main problem.
2. you can use // instead of descendant
3. you case use @ instead of attribute::
4. i would do it this way (i have not checked if it works)
=======================================================<br />
XmlNodeList nodeList;<br />
nodeList=root.SelectNodes("//folder[@ID = '34']/decendant::*") ;<br />
foreach (XmlNode folderNode in nodeList) {<br />
string nodeValue = folderNode.Attributes["ID"].Value.ToString();<br />
}<br />
=======================================================
"When the only tool you have is a hammer, a sore thumb you will have."
|
|
|
|
|
|
Hi all,
Ik agree: my first code only returns one node.
But I tried it this way:
=======================================================
XmlNodeList nodeList;
nodeList=root.SelectNodes("descendant::folder[attribute::ID='34']") ;
foreach (XmlNode folderNode in nodeList) {
string nodeValue = folderNode.Attributes["ID"].Value.ToString();
}
=======================================================
And this code also returns one node, ID='56', NOT ID='78'..
and Philips code returned an error, "invalid token".
Somebody has a clue??
Jack
|
|
|
|
|
Hi,
I believe the XPath you would want to use is "//folder[@ID='34']//*"
'selectNodes' is the choice (for your purpose) to return a list of nodes matching the supplied XPath (above).
try out this snippet (philips' with updated XPath):
XmlNodeList nodeList;
nodeList=root.SelectNodes("//folder[@ID='34']//*") ;
foreach (XmlNode folderNode in nodeList)
{
string nodeValue = folderNode.Attributes["ID"].Value.ToString();
}
hope that helps,
Ghazi
|
|
|
|
|
How to build a DataBase of data types (int, char, struct, …)?
I would like to build an ACCESS DataBase, containing information about all the data types we use.
For example:
Suppose, we have the following C/C++ code;
typedef char ARRAY_8_BYTES[8];
struct Foo1
{
int a[20];
int b;
ARRAY_8_BYTES a6;
char a[8];
};
struct Foo2
{
Foo1 foo1;
Foo1 *pFoo1;
char c[12];
};
Ideally, I’d like to have an ACCESS DataBase, containing data about the Foo1, Foo2 structures. So, I would be able to build a program, which uses this data base and (for instance) generates automatically the C code structure definitions above.
The questions I ask myself are:
1) How to organize data which is hierarchical by nature using a relational
data base such as ACCESS?
2) Are they better solutions than using ACCESS to solve this kind of
problem?
3) Do you know about other databases or commercial softwares that permit to
do this?
4) Could you please give me either a precise answer or links which can help
me?
Many, many Thanks.
|
|
|
|
|
As part of our new proposed architecture, every Web Service Method will have an identical signature in that it will take a string as its only parameter and will return a string.
I feel that I should therefore be able to create one generic method client side something like:
public string InvokeWebMethod(string url, string methodName, string parameter)
which would give me the ability to invoke any Web Method meeting the requirement above.
However, I can find no documentation as to how to achieve this easily. Using WSDL will, at the very least, (to my understinding) hard code in the name of the method but, of course, every method will have a different name - it is only the signature that will never change.
Does anyone have any ideas as to how this may be achieved?
Thanks
Bernard Yardley
|
|
|
|
|
Further to my own post above, late last night (UK time) I got this working using HttpPostClientProtocol to POST a message to the Web Service.
This worked fine twice and then stopped working reporting 'XYZ is not a valid Web Method'.
Has anyone else experienced this and knows a reason for it?
Thanks
Bernad
|
|
|
|