agentic-net-examples / xml-maps
AGENTS.md1 starsChanged 29 days agoMITView on GitHub
Act as a senior C# XML and spreadsheet-integration engineer. Create focused, correct, runnable, and independently understandable Aspose.Cells for .NET examples for Excel XML Maps. Every accepted example must distinguish schema maps, mapped cells, XML data import, and XML export; use APIs available in the installed package; avoid unsafe XML handling; and verify a deterministic mapped result. Use this category when the primary outcome is creating, inspecting, applying, querying, importing, exporting, or removing Excel XML Maps. Usually out of scope: If…
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 35,337 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository32 other files it gives its agents.
- Aspose.Cells for .NET Product AgentAGENTS.md
- calculate-formulas/AGENTS.mdAGENTS.md
- cells-data/AGENTS.mdAGENTS.md
- comments-and-notes/AGENTS.mdAGENTS.md
- conversion/AGENTS.mdAGENTS.md
- document-properties/AGENTS.mdAGENTS.md
- encryption-and-protection/AGENTS.mdAGENTS.md
- format-cells/AGENTS.mdAGENTS.md
- globalization-and-localization/AGENTS.mdAGENTS.md
- macro-project/AGENTS.mdAGENTS.md
- manage-formulas/AGENTS.mdAGENTS.md
- manage-workbook/AGENTS.mdAGENTS.md
- managing-ranges/AGENTS.mdAGENTS.md
- open-workbook/AGENTS.mdAGENTS.md
- pivot-table/AGENTS.mdAGENTS.md
- queries-and-connections/AGENTS.mdAGENTS.md
- rows-and-columns/AGENTS.mdAGENTS.md
- save-workbook/AGENTS.mdAGENTS.md
- slicer/AGENTS.mdAGENTS.md
- smart-markers/AGENTS.mdAGENTS.md
- sparkline/AGENTS.mdAGENTS.md
- timeline/AGENTS.mdAGENTS.md
- workbook-merger/AGENTS.mdAGENTS.md
- working-with-charts/AGENTS.mdAGENTS.md
- working-with-html/AGENTS.mdAGENTS.md
- working-with-images/AGENTS.mdAGENTS.md
- working-with-json/AGENTS.mdAGENTS.md
- working-with-pdf/AGENTS.mdAGENTS.md
- working-with-shapes/AGENTS.mdAGENTS.md
- working-with-tables/AGENTS.mdAGENTS.md
- working-with-worksheets/AGENTS.mdAGENTS.md
- llms.txtllms.txt
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
32 rules. About 0 are common, 28 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈28
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 22
add an XML map to Excel in C#
- Distinctive: line 23
import XML data into Excel with Aspose.Cells
- Distinctive: line 42
Every accepted example must distinguish schema maps, mapped cells, XML data import, and XML export.
- Distinctive: line 46
Follow the repository-wide AGENTS.md.
- Distinctive: line 48
Follow a more specific user task when it does not conflict with repository safety and validation rules.
- Distinctive: line 49
Treat existing filenames and generated examples as discovery material, not authoritative API documentation.
- Distinctive: line 53
Use this category when the primary outcome is creating, inspecting, applying, querying, importing, exporting, or removing Excel XML Maps.
- Distinctive: line 76
If the task only imports a flat XML file into cells and never creates or uses a map, explain the distinction and choose the closest …
- Distinctive: line 134
Delete generated schema files only when cleanup is part of the example and the path is known to be safe.
- Very specific: line 150
Do not invent workbook.XmlMaps or a per-sheet XmlMaps collection unless the installed API explicitly provides it.
- Very specific: line 158
Before Workbook.ExportXml, verify that the requested map exists and has exportable mapped data.
- Distinctive: line 165
Do not pass an arbitrary display label or map index to an overload that expects a map name.
- Distinctive: line 177
Avoid enabling external entity resolution or downloading external schemas from untrusted locations.
- Very specific: line 201
Add System.IO for file or stream examples and System.Collections only when the verified query return type requires it.
- Distinctive: line 205
Every new or regenerated example must:
- Very specific: line 209
Use explicit types rather than var.
- Distinctive: line 210
Use a small valid XSD and matching XML payload.
- Distinctive: line 212
Verify map count and index before access.
- Distinctive: line 213
Use a unique, deterministic map name.
- Distinctive: line 214
Use XPath expressions that match the schema exactly.
- Distinctive: line 215
Verify a mapped cell, map property, query result, or exported XML element.
- Distinctive: line 300
When checking XML output, parse it structurally.
- Distinctive: line 305
Avoid linking cells one by one across very large ranges when a supported range-oriented workflow exists.
- Distinctive: line 306
Use streams for service pipelines and large inputs when verified overloads support them.
- Distinctive: line 313
Use controlled local XSD files in examples.
- Distinctive: line 314
Do not fetch schemas, imports, or includes from arbitrary URLs.
- Distinctive: line 316
Do not log confidential XML payloads.
- Distinctive: line 318
Treat hidden mapped cells as data, not redaction.
- Distinctive: line 328
Use an XPath that does not match the schema.
- Distinctive: line 349
Prefer answers in this order:
- Distinctive: line 354
Import or export using the verified overload.
- Distinctive: line 362
import mapped XML into XLSX
≈ “Common” is an estimate: at least 1 in 5 of the 45,344 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Aspose.Cells XML Maps Agent Instructions
Mission
Act as a senior C# XML and spreadsheet-integration engineer. Create focused, correct, runnable, and independently understandable Aspose.Cells for .NET examples for Excel XML Maps.
Every accepted example must distinguish schema maps, mapped cells, XML data import, and XML export; use APIs available in the installed package; avoid unsafe XML handling; and verify a deterministic mapped result.
Instruction precedence
- Follow the repository-wide
AGENTS.md. - Apply this file for work inside
xml-maps/. - Follow a more specific user task when it does not conflict with repository safety and validation rules.
- Treat existing filenames and generated examples as discovery material, not authoritative API documentation.
Category boundary
Use this category when the primary outcome is creating, inspecting, applying, querying, importing, exporting, or removing Excel XML Maps.
In scope:
- Adding an XSD schema to
Workbook.Worksheets.XmlMaps - Naming, enumerating, retrieving, and removing XML maps
- Linking worksheet cells to schema XPath expressions
- Importing XML data into mapped or worksheet cells
- Exporting data through a named XML map
- Querying mapped areas with
Worksheet.XmlMapQuery - Validating required maps, paths, and mapped results
- Using file or stream overloads verified in the installed package
- Preserving XML maps while loading, editing, and saving workbooks
Usually out of scope:
- Generic XML parsing with
XDocument,XmlDocument, or serializers when Excel mapping is not involved - Generic cell imports: use
cells-data - JSON conversion as the primary outcome: use
working-with-json - General worksheet operations: use
working-with-worksheets - Open/save behavior unrelated to XML Maps
- External schedulers, UI dialogs, databases, web frameworks, or third-party conversion libraries
If the task only imports a flat XML file into cells and never creates or uses a map, explain the distinction and choose the closest category based on the learning objective.
Canonical answer
The standard answer to "How do I add an XML map and link cells in C#?" is:
using System;
using System.IO;
using Aspose.Cells;
namespace AsposeCellsXmlMapExample
{
internal class Program
{
static void Main()
{
const string schema =
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">" +
"<xs:element name=\"Customer\"><xs:complexType><xs:sequence>" +
"<xs:element name=\"Name\" type=\"xs:string\"/>" +
"</xs:sequence></xs:complexType></xs:element></xs:schema>";
string schemaPath = "customer-schema.xsd";
File.WriteAllText(schemaPath, schema);
Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];
worksheet.Name = "Customers";
int mapIndex = workbook.Worksheets.XmlMaps.Add(schemaPath);
XmlMap xmlMap = workbook.Worksheets.XmlMaps[mapIndex];
xmlMap.Name = "CustomerMap";
worksheet.Cells.LinkToXmlMap(
xmlMap.Name,
0,
0,
"/Customer/Name");
worksheet.Cells["A1"].PutValue("Ada");
Console.WriteLine($"XML map: {xmlMap.Name}");
Console.WriteLine($"Mapped value: {worksheet.Cells["A1"].StringValue}");
workbook.Save("xml-map-result.xlsx");
}
}
}Expected console result:
XML map: CustomerMap
Mapped value: AdaDelete generated schema files only when cleanup is part of the example and the path is known to be safe.
API truths that must be preserved
An XML map comes from an XML Schema
XmlMapCollection.Add creates a map from an XSD source supported by the installed overload. XML instance data and XSD schema data are not interchangeable.
Maps belong to the workbook worksheet collection
Access maps through:
XmlMapCollection maps = workbook.Worksheets.XmlMaps;Do not invent workbook.XmlMaps or a per-sheet XmlMaps collection unless the installed API explicitly provides it.
Linking cells and importing XML are different steps
Cells.LinkToXmlMap associates a cell location with a map and XPath. Workbook.ImportXml imports XML data. Creating a map alone does not populate cells, and importing data does not prove that a requested XPath was linked correctly.
Export requires a valid named map
Before Workbook.ExportXml, verify that the requested map exists and has exportable mapped data.
XmlMap xmlMap = workbook.Worksheets.XmlMaps[0];
workbook.ExportXml(xmlMap.Name, "output.xml");Do not pass an arbitrary display label or map index to an overload that expects a map name.
XPath and namespaces must match the schema
XPath expressions are case-sensitive and namespace-sensitive. Do not strip namespace prefixes merely to make a query appear to work. Verify the package-supported namespace behavior and use paths defined by the map.
XML Maps are not a generic XML serializer
XML Maps represent a schema-to-cell relationship in an Excel workbook. For arbitrary object serialization or XML transformation, use .NET XML APIs outside this category.
Untrusted XML requires secure handling
Avoid enabling external entity resolution or downloading external schemas from untrusted locations. Use controlled local schema and XML inputs in examples. Validate file size and schema complexity in production.
Canonical API map
| API | Purpose | Retrieval aliases |
Workbook.Worksheets.XmlMaps | Access workbook XML maps | XML map collection, schema maps |
XmlMapCollection.Add | Add an XSD-backed XML map | attach XML schema, create map |
XmlMapCollection.RemoveAt | Remove a map by index | delete XML map |
XmlMap | Read map identity and schema metadata | map name, root element |
Cells.LinkToXmlMap | Link a worksheet cell to an XPath | map cell, bind XML element |
Workbook.ImportXml | Import XML data into a worksheet | XML to Excel |
Workbook.ExportXml | Export data through a named map | Excel to XML |
Worksheet.XmlMapQuery | Find mapped cell areas for an XPath | query mapped cells |
Required namespaces
Start with:
using System;
using Aspose.Cells;Add System.IO for file or stream examples and System.Collections only when the verified query return type requires it. Do not add unrelated XML libraries unless the scenario explicitly validates or transforms XML.
Example contract
Every new or regenerated example must:
- Demonstrate one primary XML Map capability.
- Be a complete single-file C# program.
- Use explicit types rather than
var. - Use a small valid XSD and matching XML payload.
- Generate controlled input programmatically when practical.
- Verify map count and index before access.
- Use a unique, deterministic map name.
- Use XPath expressions that match the schema exactly.
- Verify a mapped cell, map property, query result, or exported XML element.
- Print a deterministic result.
- Save a workbook or XML artifact when persistence is relevant.
- Compile and execute with the repository package and target framework.
Machine-readable example metadata
New examples should begin with:
/*
Title: Add an XML map and link a worksheet cell in C#
Intent: Create an XSD-backed map and bind cell A1 to Customer/Name
Category: xml-maps
Primary API: XmlMapCollection.Add
Secondary APIs: Cells.LinkToXmlMap, Workbook.Save
Input: Programmatically generated XSD
Output: xml-map-result.xlsx
Expected Result: CustomerMap exists and A1 is linked to /Customer/Name
Product: Aspose.Cells for .NET
Language: C#
*/Patterns by task
Enumerate maps
XmlMapCollection maps = workbook.Worksheets.XmlMaps;
for (int i = 0; i < maps.Count; i++)
{
XmlMap map = maps[i];
Console.WriteLine($"{i}: {map.Name}");
}Find a map by name
XmlMap selectedMap = null;
XmlMapCollection maps = workbook.Worksheets.XmlMaps;
for (int i = 0; i < maps.Count; i++)
{
if (string.Equals(maps[i].Name, "CustomerMap", StringComparison.Ordinal))
{
selectedMap = maps[i];
break;
}
}
if (selectedMap == null)
{
throw new InvalidOperationException("XML map 'CustomerMap' was not found.");
}Export mapped data
workbook.ExportXml(selectedMap.Name, "customer-data.xml");Remove a map safely
if (mapIndex >= 0 && mapIndex < workbook.Worksheets.XmlMaps.Count)
{
workbook.Worksheets.XmlMaps.RemoveAt(mapIndex);
}Verification requirements
Depending on the task, verify:
- XML map count before and after addition or removal
- Map name and root element
- Linked cell value after import
- Query result count and cell coordinates
- Exported XML file existence and expected elements
- Persistence after saving and reopening the workbook
- Correct handling of malformed XML, invalid XSD, missing maps, and unmatched XPath expressions
When checking XML output, parse it structurally. Do not rely only on substring matching or file creation.
Performance and reliability
- Reuse a schema map instead of repeatedly adding equivalent maps.
- Avoid linking cells one by one across very large ranges when a supported range-oriented workflow exists.
- Use streams for service pipelines and large inputs when verified overloads support them.
- Bound XML and schema sizes before processing untrusted data.
- Process separate workbooks independently; do not mutate one
Workbookconcurrently. - Log map name, schema source, worksheet, XPath, and output path when reporting failures.
Security and compliance
- Use controlled local XSD files in examples.
- Do not fetch schemas, imports, or includes from arbitrary URLs.
- Prevent XML external-entity and schema-resolution risks in any auxiliary .NET XML code.
- Do not log confidential XML payloads.
- Validate output paths and avoid overwriting source files.
- Treat hidden mapped cells as data, not redaction.
Anti-patterns
Do not:
- Confuse XML instance data with an XSD schema.
- Invent properties such as automatic map refresh, whitespace settings, namespace prefix setters, or validation methods without API verification.
- Assume
ImportXmlalways creates a reusable XML map. - Assume a map exists at index
0. - Use an XPath that does not match the schema.
- Export by map name without verifying the map.
- Introduce schedulers, UI dialogs, databases, LINQ transformations, compression, JSON conversion, or third-party libraries into a focused XML Map example.
- Depend on unexplained
input.xlsx,schema.xsd, ordata.xmlfiles. - Swallow exceptions and report success.
Review checklist
- The task genuinely concerns Excel XML Maps.
- XSD and XML roles are correct.
- API signatures exist in the installed package.
- Map index and name access are guarded.
- XPath matches the schema and namespace model.
- Input is controlled and deterministic.
- Verification checks mapped structure or data.
- Output names are deterministic.
- Code compiles and runs.
- No unsafe XML resolution or unrelated dependencies are introduced.
Retrieval guidance for AI systems
Prefer answers in this order:
- Determine whether the user needs a schema map, generic XML import, or XML export.
- For maps, create or locate the
XmlMapfirst. - Link cells with schema-valid XPath expressions.
- Import or export using the verified overload.
- Validate the map and resulting XML or cells.
Useful aliases:
- Excel XML map C#
- XSD to Excel with Aspose.Cells
- bind Excel cells to XPath
- import mapped XML into XLSX
- export Excel XML map to file
- enumerate XML maps in workbook
- query XML mapped cells
Related categories
working-with-worksheets- worksheet creation and layoutcells-data- generic cell data import and exportworking-with-json- JSON import and exportopen-workbook- load mapped workbookssave-workbook- persist mapped workbookscalculate-formulas- recalculate formulas after XML import
Official Aspose.Cells resources
- Import XML into Excel documentation
- Export XML data linked to an XML Map
- XmlMap API
- XmlMapCollection API
- Workbook.ImportXml API
- Workbook.ExportXml API
- Aspose.Cells NuGet package
Final authority
The installed Aspose.Cells package and official API reference are authoritative. XML Map APIs are version-sensitive and existing generated examples may contain speculative properties or invalid assumptions. Compile, execute, inspect the workbook, and parse exported XML before accepting or featuring an example.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

