0

what im doing right now. is changing the xml tag to its counterpart in xhtml.

the problem so far is. there are some extra tag that i don't need.

the program i'm doing right now is. changing the xml tag and removing some of the tags i dont need. is there any better way to do this?

the requirement is. the output must be html5.

thank you

example xml

<PublisherInfo>
    <PublisherName value="1">Askquestionzero Publisher</PublisherName>
    <PublisherLocation>Ph</PublisherLocation>
    <PublisherImprintName>Askquestionzero</PublisherImprintName>
    <PublisherLogo>
      <Tada>Remove this value and its content</Tada>
    </PublisherLogo>
    <PublisherLogo>
      <Tada>Remove this value and its content</Tada>
    </PublisherLogo>
    <PublisherURL>Askquestionzero.com</PublisherURL>
    <Title>Some Title here</title>

    <Para>This is some text for the paragraph <emphasis><italic>Chapter</italic></emphasis></Para>

  </PublisherInfo>

desired output

  <h1>Askquestionzero Publisher</h1>
  <h2>Some Title here</h2>
  <p>This is some text for the paragraph <i>Chapter</i></p>

in the example above. i dont need the other node. and what i need is to get the content of Title node. and the para node. and remove the emphasis node and change the italic node to I.

  • Can you give a sample of your XML. How it looks like and what output you probably might want as an output. Please also attach any methodology you applied to get the output – Mohit S Jul 14 '16 at 07:00
  • It's not an exact duplicate, but it covers the topic you're trying to master. And I believe that an answer here would be "your solution is XSLT" and the next answer would be: how do I use XSLT in C#? – Matías Fidemraizer Jul 14 '16 at 07:27
  • @MohitShrivastava i already updated. the question. matias. using xslt is the best option? because i dont have xslt. so creating xslt? is faster than creating a program to remove the node/tag that i dont need? – askquestionzero Jul 14 '16 at 07:42
  • I believe a better duplicate is [How to convert XML to Html in c#?](http://stackoverflow.com/q/8018367/1497596). While XSLT is one way to do this, that question (like this one) leaves open the possibility of other approaches. (For example, [LINQ-to-XML](http://stackoverflow.com/tags/linq-to-xml/info).) – DavidRR Jul 14 '16 at 13:54
  • *Because I dont have xslt*...most general purpose languages including C# come equipped with an XSLT 1.0 processor. Even PowerShell has one! – Parfait Jul 14 '16 at 19:17
  • `xslt` is the way to go, please see my answer here => https://stackoverflow.com/a/58930747/3057246 – Vinod Srivastav Nov 25 '21 at 22:01

0 Answers0