|
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
|
|
|
|
|
Before I rush off and write the thing, would anyone be interested in an article explaining how to use SAX and DOM together to create an extensible mechanism for dealing with bulk (>1Gb) XML documents?
Steve S
|
|
|
|
|
I want to use MSXML to create a XML file like this
<?xml version="1.0" encoding="UTF-8"?>
<Schema xmlns="http://www.w3.org/2001/XMLSchema">
<element name="Features" type="wfs:featuresType" substitutionGroup="gml:_FeatureCollection"/>
</Schema>
Here is my source coede
#include <stdio.h>
#import <msxml4.dll>
using namespace MSXML2;
int main(int argc, char* argv[])
{
IXMLDOMDocument2Ptr pXMLDom;
HRESULT hr;
CoInitialize(NULL);
hr = pXMLDom.CreateInstance(__uuidof(DOMDocument40));
if (FAILED(hr))
{
printf("Failed to CreateInstance on an XML DOM");
return NULL;
}
pXMLDom->preserveWhiteSpace = VARIANT_TRUE;
IXMLDOMProcessingInstructionPtr pi;
pi = pXMLDom->createProcessingInstruction("xml", "version='1.0' encoding='UTF-8'");
if (pi != NULL)
{
pXMLDom->appendChild(pi);
pi.Release();
}
IXMLDOMElementPtr pe;
IXMLDOMNodePtr nodePtr;
_variant_t varTyp((short)NODE_ELEMENT);
nodePtr=pXMLDom->createNode(varTyp,"Schema","http://www.w3.org/2001/XMLSchema");
pXMLDom->appendChild(nodePtr);
nodePtr.Release();
pe = pXMLDom->documentElement;
IXMLDOMAttributePtr pa;
pXMLDom->documentElement->appendChild(pXMLDom->createTextNode("\n\t"));
IXMLDOMDocumentFragmentPtr pdf;
pdf = pXMLDom->createDocumentFragment();
pe = pXMLDom->createElement("element");
pe->setAttribute("name","Features");
pe->setAttribute("type","wfs:featuresType");
pe->setAttribute("substitutionGroup","gml:_FeatureCollection");
pdf->appendChild(pe);
pe.Release();
pXMLDom->documentElement->appendChild(pdf);
pdf.Release();
pXMLDom->documentElement->appendChild(pXMLDom->createTextNode("\n\t"));
hr = pXMLDom->save("dynaDom.xml");
if (FAILED(hr))
{
printf("Failed to save DOM to dynaDom.xml\n");
}
else
{
printf("DOM saved to dynamDom.xml\n");
}
if (pXMLDom) pXMLDom.Release();
CoUninitialize();
return 0;
}
But the output is:
<?xml version="1.0" encoding="UTF-8"?>
<Schema xmlns="http://www.w3.org/2001/XMLSchema">
<element xmlns="" name="Features" type="wfs:featuresType" substitutionGroup="gml:_FeatureCollection"/>
</Schema>
you can see that :there is an attribute "xmlns" within the "element" tag and the value of the attribute is nothing.
I don't want the out come is this,Please Help!
|
|
|
|
|
When you create the "element" node you need so specify that it is part of the same namspace as the Schema element.
Otherwise what you are saying is that the element node does not belong to any namespace, hence the empty xmlns attribute.
Something like :
pXMLDom->createElement("element",","http://www.w3.org/2001/XMLSchema");
|
|
|
|
|
Thank you for your help!
This question has been resolved .
|
|
|
|
|
I am trying to store an article in an xml file and use an xsl transform to create an html version of the article. I am having no problems with the article text, heading and etc. however i wish to place a simple image tag that gets the image url from the xml file and outputs the tag to the html. I am a newcomer to xml and have been unable to make this work. any help would be greatly appreciated.
|
|
|
|
|
What have you tried so far?
How about posting examples of the xml and xsl that you are using.
|
|
|
|
|
Me and some partners are together going to construct a XML-format for storing data. New datatypes will come in the future so the XML-tags will grow. Are there a common way for all of us to handle the way to build up valid documents.
Pleased for all suggestions
...and justice for all
APe
|
|
|
|
|
Look up XSD and Schema's
Lots of information.
|
|
|
|
|
how can i transform an xml using xslt without loading the xslt from a file?
I have two strings containing the source of the xml and xslt
I can load an xmldocument object using the InnerText property, but then i can't find a way to transform it since all the methods available for loading an xslt document and transforming the xml document involve an xslt file
|
|
|
|
|
If you are using .Net Framework try following:
XmlDocument doc=new XmlDocument();
doc.LoadXml(xmlString);<br /><br />
XslTransform xslt=new XslTransform();
TextReader txt=new StringReader(xsltString);
XmlReader reader=new XmlTextReader(txt);
xslt.Load(reader,null,null);<br />
<br />
xslt.Transform(...);
|
|
|
|
|
Look at the loadXML() method. It takes a string of XML and loads it into the MSXML4::IXMLDOMDocument2 object.
|
|
|
|
|
Sub : How to use Amazon Web Services..
Hi all...
Please let me know How to start with amazon web services..
I'm not finding any XML or REST Query format to send request to amazon..
I've purchased Seller account but How to use that to upload Items..I don't know...
Please help me getting start..
I hope some one definatly know about this
e-mail if attachment at sumit_kapoor1980@hotmail.com
Thanks...
..---Sumit Kapoor---
|
|
|
|
|
Stop Cross posting and use your eyes: The answer is already on Code Project, if you would care to look.
My suggestion is to use the little search box near the top of this page and type "Amazon web services", ensure the drop down says "Articles" and then press "Go". You'll be amazed at what you can find.
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
|
|
|
|