Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting back XML file after it's been processed by XSLT 1

Status
Not open for further replies.

AT76

Technical User
Apr 14, 2005
460
0
0
US
Hi,

In my VS project I have an XML doc. I created an XSLT that sorts a node in my XML doc. After I do the transformation of the XML file I would like to re-use it in my program.

I'm not sure how to call it back...

Here's what I have:
Code:
        xDoc.Load(xmlPath);
        XslCompiledTransform xslt = new XslCompiledTransform();
        xslt.Load(Server.MapPath("Sort.xsl"));
I would like to use the output XML file that sort.xsl created into my next line of code:

Code:
audienceList = xDoc.SelectNodes("/dataroot/...");

Could someone help me using the newly created sorted XML doc.

Thanks!
 
it would look something like this
Code:
StringWriter sortedNodes = new StringWriter();
xslt.Transform(xDoc, null, sortedNodes);

XmlDocument sortedDocument = new XmlDocument();
sortedDocument.LoadXml(sortedNodes);

XmlNodeList audienceList = sortedDocument.SelectNodes("/dataroot/...");

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Jason,

Your example worked great. The only addition I had to make was:


Code:
sortedDocument.LoadXml([COLOR=red]ConvertToString[/color].(sortedNodes));

Thank you!
 
this would also work with the stringwrite object
Code:
sortedDocument.LoadXml(sortedNodes.ToString());

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top